diff --git a/.env.development b/.env.development index 0b93117ec..4f23aa318 100644 --- a/.env.development +++ b/.env.development @@ -1,16 +1,5 @@ -NEXT_PUBLIC_CHAIN_ID = "56" NEXT_PUBLIC_GTAG = "GTM-PXLD3XW" -# 10+ nodes balanced, US/EU -NEXT_PUBLIC_NODE_1 = "https://bsc-dataseed1.ninicoin.io" - -# 10+ nodes balanced, US/EU -NEXT_PUBLIC_NODE_2 = "https://bsc-dataseed1.defibit.io" - -# 10+ nodes balanced in each region, global -NEXT_PUBLIC_NODE_3 = "https://bsc-dataseed.binance.org" - -NEXT_PUBLIC_NODE_PRODUCTION = "https://nodes.pancakeswap.com" NEXT_PUBLIC_GRAPH_API_PROFILE = "https://api.thegraph.com/subgraphs/name/pancakeswap/profile" NEXT_PUBLIC_GRAPH_API_PREDICTION_BNB = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction-v2" diff --git a/.env.production b/.env.production index f93a2c710..c987a08a0 100644 --- a/.env.production +++ b/.env.production @@ -1,18 +1,5 @@ -NEXT_PUBLIC_CHAIN_ID = "56" NEXT_PUBLIC_GTAG = "GTM-TLF66T4" -# 10+ nodes balanced, US/EU -NEXT_PUBLIC_NODE_1 = "https://bsc-dataseed1.ninicoin.io" - -# 10+ nodes balanced, US/EU -NEXT_PUBLIC_NODE_2 = "https://bsc-dataseed1.defibit.io" - -# 10+ nodes balanced in each region, global -NEXT_PUBLIC_NODE_3 = "https://bsc-dataseed.binance.org" - -# Google Cloud Infrastructure Endpoint - Global -NEXT_PUBLIC_NODE_PRODUCTION = "https://nodes.pancakeswap.com" - NEXT_PUBLIC_GRAPH_API_PROFILE = "https://api.thegraph.com/subgraphs/name/pancakeswap/profile" NEXT_PUBLIC_GRAPH_API_PREDICTION_BNB = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction-v2" NEXT_PUBLIC_GRAPH_API_PREDICTION_CAKE = "https://api.thegraph.com/subgraphs/name/pancakeswap/prediction-cake" diff --git a/.env.test b/.env.test deleted file mode 100644 index 7e82c76d3..000000000 --- a/.env.test +++ /dev/null @@ -1,7 +0,0 @@ -NEXT_PUBLIC_CHAIN_ID = "56" - -NEXT_PUBLIC_NODE_1 = "https://bsc-dataseed1.ninicoin.io" -NEXT_PUBLIC_NODE_2 = "https://bsc-dataseed1.ninicoin.io" -NEXT_PUBLIC_NODE_3 = "https://bsc-dataseed1.ninicoin.io" - -NEXT_PUBLIC_NODE_PRODUCTION = "https://nodes.pancakeswap.com" diff --git a/.env.testnet b/.env.testnet deleted file mode 100644 index 12c1f8d70..000000000 --- a/.env.testnet +++ /dev/null @@ -1,5 +0,0 @@ -NEXT_PUBLIC_CHAIN_ID = "97" -NEXT_PUBLIC_NODE_PRODUCTION = "" -NEXT_PUBLIC_NODE_1 = "https://data-seed-prebsc-1-s1.binance.org:8545" -NEXT_PUBLIC_NODE_2 = "https://data-seed-prebsc-2-s1.binance.org:8545" -NEXT_PUBLIC_NODE_3 = "https://data-seed-prebsc-1-s3.binance.org:8545" \ No newline at end of file diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..c44525998 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +packages/swap-sdk/**/*.ts \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 3be3b9606..4b46a9dde 100644 --- a/jest.config.js +++ b/jest.config.js @@ -9,6 +9,7 @@ const customJestConfig = { testPathIgnorePatterns: ['/cypress/', '/src/config/__tests__/', '/packages'], moduleNameMapper: { '^@pancakeswap/uikit': '/packages/uikit/src', + '^@pancakeswap/sdk': '/packages/swap-sdk/src', }, moduleDirectories: ['node_modules', 'src'], testTimeout: 20000, diff --git a/next.config.js b/next.config.js index c4fac0c2a..f7f44fe17 100644 --- a/next.config.js +++ b/next.config.js @@ -3,7 +3,7 @@ const { withSentryConfig } = require('@sentry/nextjs') const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: process.env.ANALYZE === 'true', }) -const withTM = require('next-transpile-modules')(['@pancakeswap/uikit']) +const withTM = require('next-transpile-modules')(['@pancakeswap/uikit', '@pancakeswap/sdk']) const sentryWebpackPluginOptions = process.env.VERCEL_ENV === 'production' diff --git a/package.json b/package.json index 4cbf9ac3b..00ed2b7dc 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@ethersproject/units": "^5.5.0", "@gelatonetwork/limit-orders-lib": "^4.1.0", "@next/bundle-analyzer": "^12.0.7", - "@pancakeswap/sdk": "^2.4.5", + "@pancakeswap/sdk": "3.0.0-2", "@reduxjs/toolkit": "^1.8.2", "@sentry/nextjs": "6.19.6", "@uniswap/token-lists": "^1.0.0-beta.19", diff --git a/packages/swap-sdk/.babelrc b/packages/swap-sdk/.babelrc new file mode 100644 index 000000000..5ec58a40b --- /dev/null +++ b/packages/swap-sdk/.babelrc @@ -0,0 +1,3 @@ +{ + "plugins": [] // "transform-jsbi-to-bigint" +} diff --git a/packages/swap-sdk/LICENSE b/packages/swap-sdk/LICENSE new file mode 100644 index 000000000..93e6b3073 --- /dev/null +++ b/packages/swap-sdk/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Noah Zinsmeister + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/packages/swap-sdk/README.md b/packages/swap-sdk/README.md new file mode 100644 index 000000000..9f863fbd5 --- /dev/null +++ b/packages/swap-sdk/README.md @@ -0,0 +1,53 @@ +# Pancakeswap SDK + +Forked from the [Uniswap SDK](https://github.com/Uniswap/uniswap-v2-sdk/commit/a88048e9c4198a5bdaea00883ca00c8c8e582605). + +You can refer to the Uniswap SDK documentation [uniswap.org](https://docs.uniswap.org/sdk/2.0.0/). + +## Running tests + +To run the tests, follow these steps. You must have at least node v10 and [yarn](https://yarnpkg.com/) installed. + +First clone the repository: + +```sh +git clone https://github.com/pancakeswap/pancake-swap-sdk.git +``` + +Move into the pancakeswap-sdk working directory + +```sh +cd pancakeswap-sdk/ +``` + +Install dependencies + +```sh +yarn install +``` + +Run tests + +```sh +yarn test +``` + +You should see output like the following: + +```sh +yarn run v1.22.4 +$ tsdx test + PASS test/constants.test.ts + PASS test/pair.test.ts + PASS test/fraction.test.ts + PASS test/miscellaneous.test.ts + PASS test/entities.test.ts + PASS test/trade.test.ts + +Test Suites: 1 skipped, 6 passed, 6 of 7 total +Tests: 3 skipped, 82 passed, 85 total +Snapshots: 0 total +Time: 5.091s +Ran all test suites. +✨ Done in 6.61s. +``` diff --git a/packages/swap-sdk/jest.config.js b/packages/swap-sdk/jest.config.js new file mode 100644 index 000000000..c587684b4 --- /dev/null +++ b/packages/swap-sdk/jest.config.js @@ -0,0 +1,18 @@ +module.exports = { + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + transform: { + '^.+\\.(t|j)sx?$': [ + '@swc/jest', + { + jsc: { + transform: { + react: { + runtime: 'automatic', + }, + }, + }, + }, + ], + }, + testEnvironment: 'jsdom', +} diff --git a/packages/swap-sdk/package.json b/packages/swap-sdk/package.json new file mode 100644 index 000000000..1530d2e0c --- /dev/null +++ b/packages/swap-sdk/package.json @@ -0,0 +1,60 @@ +{ + "name": "@pancakeswap/sdk", + "license": "MIT", + "version": "3.0.0-2", + "description": "🛠 An SDK for building applications on top of Pancakeswap.", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "files": [ + "dist" + ], + "repository": "https://github.com/pancakeswap/pancake-swap-sdk.git", + "keywords": [ + "pancakeswap", + "bsc" + ], + "module": "dist/sdk.esm.js", + "scripts": { + "lint": "tsdx lint src test", + "build": "tsup src/index.ts --format esm,cjs --dts", + "start": "tsup src/index.tsx --format esm,cjs --watch --dts", + "test": "jest", + "prepublishOnly": "yarn run build" + }, + "dependencies": { + "big.js": "^5.2.2", + "decimal.js-light": "^2.5.0", + "jsbi": "^3.1.4", + "tiny-invariant": "^1.1.0", + "tiny-warning": "^1.0.3", + "toformat": "^2.0.0" + }, + "peerDependencies": { + "@ethersproject/address": "^5.0.0", + "@ethersproject/contracts": "^5.0.0", + "@ethersproject/networks": "^5.0.0", + "@ethersproject/providers": "^5.0.0", + "@ethersproject/solidity": "^5.0.0" + }, + "devDependencies": { + "@ethersproject/address": "^5.0.2", + "@ethersproject/contracts": "^5.0.2", + "@ethersproject/networks": "^5.0.2", + "@ethersproject/providers": "^5.0.5", + "@ethersproject/solidity": "^5.0.2", + "@swc/core": "^1.2.215", + "@swc/jest": "^0.2.21", + "@types/big.js": "^4.0.5", + "@types/jest": "^24.0.25", + "babel-plugin-transform-jsbi-to-bigint": "^1.3.1", + "tsup": "^5.10.1" + }, + "engines": { + "node": ">=10" + }, + "prettier": { + "printWidth": 120, + "semi": false, + "singleQuote": true + } +} diff --git a/packages/swap-sdk/src/abis/ERC20.json b/packages/swap-sdk/src/abis/ERC20.json new file mode 100644 index 000000000..e8a2da620 --- /dev/null +++ b/packages/swap-sdk/src/abis/ERC20.json @@ -0,0 +1,20 @@ +[ + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/packages/swap-sdk/src/abis/IPancakePair.json b/packages/swap-sdk/src/abis/IPancakePair.json new file mode 100644 index 000000000..a5aae8e2a --- /dev/null +++ b/packages/swap-sdk/src/abis/IPancakePair.json @@ -0,0 +1,707 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1In", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint112", + "name": "reserve0", + "type": "uint112" + }, + { + "indexed": false, + "internalType": "uint112", + "name": "reserve1", + "type": "uint112" + } + ], + "name": "Sync", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MINIMUM_LIQUIDITY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getReserves", + "outputs": [ + { + "internalType": "uint112", + "name": "reserve0", + "type": "uint112" + }, + { + "internalType": "uint112", + "name": "reserve1", + "type": "uint112" + }, + { + "internalType": "uint32", + "name": "blockTimestampLast", + "type": "uint32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "kLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "liquidity", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "price0CumulativeLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "price1CumulativeLast", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "skim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount0Out", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Out", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "sync", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/packages/swap-sdk/src/constants.ts b/packages/swap-sdk/src/constants.ts new file mode 100644 index 000000000..440fa56d1 --- /dev/null +++ b/packages/swap-sdk/src/constants.ts @@ -0,0 +1,59 @@ +import JSBI from 'jsbi' + +// exports for external consumption +export type BigintIsh = JSBI | number | string + +export enum ChainId { + // ETHEREUM = 1, + // RINKEBY = 4, + BSC = 56, + BSC_TESTNET = 97, +} + +export enum TradeType { + EXACT_INPUT, + EXACT_OUTPUT, +} + +export enum Rounding { + ROUND_DOWN, + ROUND_HALF_UP, + ROUND_UP, +} + +export const FACTORY_ADDRESS = '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73' + +export const FACTORY_ADDRESS_MAP = { + [ChainId.BSC]: FACTORY_ADDRESS, + [ChainId.BSC_TESTNET]: '0x6725f303b657a9451d8ba641348b6761a6cc7a17', +} + +export const INIT_CODE_HASH = '0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5' + +export const INIT_CODE_HASH_MAP = { + [ChainId.BSC]: INIT_CODE_HASH, + [ChainId.BSC_TESTNET]: '0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66', +} + +export const MINIMUM_LIQUIDITY = JSBI.BigInt(1000) + +// exports for internal consumption +export const ZERO = JSBI.BigInt(0) +export const ONE = JSBI.BigInt(1) +export const TWO = JSBI.BigInt(2) +export const THREE = JSBI.BigInt(3) +export const FIVE = JSBI.BigInt(5) +export const TEN = JSBI.BigInt(10) +export const _100 = JSBI.BigInt(100) +export const FEES_NUMERATOR = JSBI.BigInt(9975) +export const FEES_DENOMINATOR = JSBI.BigInt(10000) + +export enum SolidityType { + uint8 = 'uint8', + uint256 = 'uint256', +} + +export const SOLIDITY_TYPE_MAXIMA = { + [SolidityType.uint8]: JSBI.BigInt('0xff'), + [SolidityType.uint256]: JSBI.BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), +} diff --git a/packages/swap-sdk/src/declarations.d.ts b/packages/swap-sdk/src/declarations.d.ts new file mode 100644 index 000000000..a5a680385 --- /dev/null +++ b/packages/swap-sdk/src/declarations.d.ts @@ -0,0 +1 @@ +declare module 'toformat' diff --git a/packages/swap-sdk/src/entities/currency.ts b/packages/swap-sdk/src/entities/currency.ts new file mode 100644 index 000000000..989bec418 --- /dev/null +++ b/packages/swap-sdk/src/entities/currency.ts @@ -0,0 +1,37 @@ +import JSBI from 'jsbi' + +import { SolidityType } from '../constants' +import { validateSolidityTypeInstance } from '../utils' + +/** + * 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. + */ +export class Currency { + public readonly decimals: number + public readonly symbol?: string + public readonly name?: string + + /** + * The only instance of the base class `Currency`. + */ + public static readonly ETHER: Currency = new Currency(18, 'BNB', 'BNB') + + /** + * 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 + */ + protected constructor(decimals: number, symbol?: string, name?: string) { + validateSolidityTypeInstance(JSBI.BigInt(decimals), SolidityType.uint8) + + this.decimals = decimals + this.symbol = symbol + this.name = name + } +} + +const ETHER = Currency.ETHER +export { ETHER } diff --git a/packages/swap-sdk/src/entities/fractions/currencyAmount.ts b/packages/swap-sdk/src/entities/fractions/currencyAmount.ts new file mode 100644 index 000000000..a911c03b7 --- /dev/null +++ b/packages/swap-sdk/src/entities/fractions/currencyAmount.ts @@ -0,0 +1,69 @@ +import { currencyEquals } from '../token' +import { Currency, ETHER } from '../currency' +import invariant from 'tiny-invariant' +import JSBI from 'jsbi' +import _Big from 'big.js' +import toFormat from 'toformat' + +import { BigintIsh, Rounding, TEN, SolidityType } from '../../constants' +import { parseBigintIsh, validateSolidityTypeInstance } from '../../utils' +import { Fraction } from './fraction' + +const Big = toFormat(_Big) + +export class CurrencyAmount extends Fraction { + public readonly currency: Currency + + /** + * Helper that calls the constructor with the ETHER currency + * @param amount ether amount in wei + */ + public static ether(amount: BigintIsh): CurrencyAmount { + return new CurrencyAmount(ETHER, amount) + } + + // amount _must_ be raw, i.e. in the native representation + protected constructor(currency: Currency, amount: BigintIsh) { + const parsedAmount = parseBigintIsh(amount) + validateSolidityTypeInstance(parsedAmount, SolidityType.uint256) + + super(parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(currency.decimals))) + this.currency = currency + } + + public get raw(): JSBI { + return this.numerator + } + + public add(other: CurrencyAmount): CurrencyAmount { + invariant(currencyEquals(this.currency, other.currency), 'TOKEN') + return new CurrencyAmount(this.currency, JSBI.add(this.raw, other.raw)) + } + + public subtract(other: CurrencyAmount): CurrencyAmount { + invariant(currencyEquals(this.currency, other.currency), 'TOKEN') + return new CurrencyAmount(this.currency, JSBI.subtract(this.raw, other.raw)) + } + + public toSignificant( + significantDigits: number = 6, + format?: object, + rounding: Rounding = Rounding.ROUND_DOWN + ): string { + return super.toSignificant(significantDigits, format, rounding) + } + + public toFixed( + decimalPlaces: number = this.currency.decimals, + format?: object, + rounding: Rounding = Rounding.ROUND_DOWN + ): string { + invariant(decimalPlaces <= this.currency.decimals, 'DECIMALS') + return super.toFixed(decimalPlaces, format, rounding) + } + + public toExact(format: object = { groupSeparator: '' }): string { + Big.DP = this.currency.decimals + return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(format) + } +} diff --git a/packages/swap-sdk/src/entities/fractions/fraction.ts b/packages/swap-sdk/src/entities/fractions/fraction.ts new file mode 100644 index 000000000..065d44441 --- /dev/null +++ b/packages/swap-sdk/src/entities/fractions/fraction.ts @@ -0,0 +1,173 @@ +import invariant from 'tiny-invariant' +import JSBI from 'jsbi' +import _Decimal from 'decimal.js-light' +import _Big from 'big.js' +import toFormat from 'toformat' + +import { BigintIsh, Rounding } from '../../constants' +import { ONE } from '../../constants' +import { parseBigintIsh } from '../../utils' + +const Decimal = toFormat(_Decimal) +const Big = toFormat(_Big) + +const toSignificantRounding = { + [Rounding.ROUND_DOWN]: Decimal.ROUND_DOWN, + [Rounding.ROUND_HALF_UP]: Decimal.ROUND_HALF_UP, + [Rounding.ROUND_UP]: Decimal.ROUND_UP, +} + +const enum RoundingMode { + /** + * Rounds towards zero. + * I.e. truncate, no rounding. + */ + RoundDown = 0, + /** + * Rounds towards nearest neighbour. + * If equidistant, rounds away from zero. + */ + RoundHalfUp = 1, + /** + * Rounds towards nearest neighbour. + * If equidistant, rounds towards even neighbour. + */ + RoundHalfEven = 2, + /** + * Rounds away from zero. + */ + RoundUp = 3, +} + +const toFixedRounding = { + [Rounding.ROUND_DOWN]: RoundingMode.RoundDown, + [Rounding.ROUND_HALF_UP]: RoundingMode.RoundHalfUp, + [Rounding.ROUND_UP]: RoundingMode.RoundUp, +} + +export class Fraction { + public readonly numerator: JSBI + public readonly denominator: JSBI + + public constructor(numerator: BigintIsh, denominator: BigintIsh = ONE) { + this.numerator = parseBigintIsh(numerator) + this.denominator = parseBigintIsh(denominator) + } + + // performs floor division + public get quotient(): JSBI { + return JSBI.divide(this.numerator, this.denominator) + } + + // remainder after floor division + public get remainder(): Fraction { + return new Fraction(JSBI.remainder(this.numerator, this.denominator), this.denominator) + } + + public invert(): Fraction { + return new Fraction(this.denominator, this.numerator) + } + + public add(other: Fraction | BigintIsh): Fraction { + const 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) + ) + } + + public subtract(other: Fraction | BigintIsh): Fraction { + const 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) + ) + } + + public lessThan(other: Fraction | BigintIsh): boolean { + const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) + return JSBI.lessThan( + JSBI.multiply(this.numerator, otherParsed.denominator), + JSBI.multiply(otherParsed.numerator, this.denominator) + ) + } + + public equalTo(other: Fraction | BigintIsh): boolean { + const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) + return JSBI.equal( + JSBI.multiply(this.numerator, otherParsed.denominator), + JSBI.multiply(otherParsed.numerator, this.denominator) + ) + } + + public greaterThan(other: Fraction | BigintIsh): boolean { + const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) + return JSBI.greaterThan( + JSBI.multiply(this.numerator, otherParsed.denominator), + JSBI.multiply(otherParsed.numerator, this.denominator) + ) + } + + public multiply(other: Fraction | BigintIsh): Fraction { + const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) + return new Fraction( + JSBI.multiply(this.numerator, otherParsed.numerator), + JSBI.multiply(this.denominator, otherParsed.denominator) + ) + } + + public divide(other: Fraction | BigintIsh): Fraction { + const otherParsed = other instanceof Fraction ? other : new Fraction(parseBigintIsh(other)) + return new Fraction( + JSBI.multiply(this.numerator, otherParsed.denominator), + JSBI.multiply(this.denominator, otherParsed.numerator) + ) + } + + public toSignificant( + significantDigits: number, + format: object = { groupSeparator: '' }, + rounding: Rounding = Rounding.ROUND_HALF_UP + ): string { + invariant(Number.isInteger(significantDigits), `${significantDigits} is not an integer.`) + invariant(significantDigits > 0, `${significantDigits} is not positive.`) + + Decimal.set({ precision: significantDigits + 1, rounding: toSignificantRounding[rounding] }) + const quotient = new Decimal(this.numerator.toString()) + .div(this.denominator.toString()) + .toSignificantDigits(significantDigits) + return quotient.toFormat(quotient.decimalPlaces(), format) + } + + public toFixed( + decimalPlaces: number, + format: object = { groupSeparator: '' }, + rounding: Rounding = Rounding.ROUND_HALF_UP + ): string { + invariant(Number.isInteger(decimalPlaces), `${decimalPlaces} is not an integer.`) + invariant(decimalPlaces >= 0, `${decimalPlaces} is negative.`) + + Big.DP = decimalPlaces + Big.RM = toFixedRounding[rounding] + return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format) + } + + /** + * Helper method for converting any super class back to a fraction + */ + public get asFraction(): Fraction { + return new Fraction(this.numerator, this.denominator) + } +} diff --git a/packages/swap-sdk/src/entities/fractions/index.ts b/packages/swap-sdk/src/entities/fractions/index.ts new file mode 100644 index 000000000..6a7689d61 --- /dev/null +++ b/packages/swap-sdk/src/entities/fractions/index.ts @@ -0,0 +1,5 @@ +export * from './fraction' +export * from './percent' +export * from './tokenAmount' +export * from './currencyAmount' +export * from './price' diff --git a/packages/swap-sdk/src/entities/fractions/percent.ts b/packages/swap-sdk/src/entities/fractions/percent.ts new file mode 100644 index 000000000..092e7aa40 --- /dev/null +++ b/packages/swap-sdk/src/entities/fractions/percent.ts @@ -0,0 +1,14 @@ +import { Rounding, _100 } from '../../constants' +import { Fraction } from './fraction' + +const _100_PERCENT = new Fraction(_100) + +export class Percent extends Fraction { + public toSignificant(significantDigits: number = 5, format?: object, rounding?: Rounding): string { + return this.multiply(_100_PERCENT).toSignificant(significantDigits, format, rounding) + } + + public toFixed(decimalPlaces: number = 2, format?: object, rounding?: Rounding): string { + return this.multiply(_100_PERCENT).toFixed(decimalPlaces, format, rounding) + } +} diff --git a/packages/swap-sdk/src/entities/fractions/price.ts b/packages/swap-sdk/src/entities/fractions/price.ts new file mode 100644 index 000000000..87a5db535 --- /dev/null +++ b/packages/swap-sdk/src/entities/fractions/price.ts @@ -0,0 +1,76 @@ +import { Token } from '../token' +import { TokenAmount } from './tokenAmount' +import { currencyEquals } from '../token' +import invariant from 'tiny-invariant' +import JSBI from 'jsbi' + +import { BigintIsh, Rounding, TEN } from '../../constants' +import { Currency } from '../currency' +import { Route } from '../route' +import { Fraction } from './fraction' +import { CurrencyAmount } from './currencyAmount' + +export class Price extends Fraction { + public readonly baseCurrency: Currency // input i.e. denominator + public readonly quoteCurrency: Currency // output i.e. numerator + public readonly scalar: Fraction // used to adjust the raw fraction w/r/t the decimals of the {base,quote}Token + + public static fromRoute(route: Route): Price { + const prices: Price[] = [] + for (const [i, pair] of route.pairs.entries()) { + 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((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0]) + } + + // denominator and numerator _must_ be raw, i.e. in the native representation + public constructor(baseCurrency: Currency, quoteCurrency: Currency, denominator: BigintIsh, numerator: BigintIsh) { + super(numerator, denominator) + + this.baseCurrency = baseCurrency + this.quoteCurrency = quoteCurrency + this.scalar = new Fraction( + JSBI.exponentiate(TEN, JSBI.BigInt(baseCurrency.decimals)), + JSBI.exponentiate(TEN, JSBI.BigInt(quoteCurrency.decimals)) + ) + } + + public get raw(): Fraction { + return new Fraction(this.numerator, this.denominator) + } + + public get adjusted(): Fraction { + return super.multiply(this.scalar) + } + + public invert(): Price { + return new Price(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator) + } + + public multiply(other: Price): Price { + invariant(currencyEquals(this.quoteCurrency, other.baseCurrency), 'TOKEN') + const fraction = super.multiply(other) + return new Price(this.baseCurrency, other.quoteCurrency, fraction.denominator, fraction.numerator) + } + + // performs floor division on overflow + public quote(currencyAmount: CurrencyAmount): CurrencyAmount { + invariant(currencyEquals(currencyAmount.currency, this.baseCurrency), 'TOKEN') + if (this.quoteCurrency instanceof Token) { + return new TokenAmount(this.quoteCurrency, super.multiply(currencyAmount.raw).quotient) + } + return CurrencyAmount.ether(super.multiply(currencyAmount.raw).quotient) + } + + public toSignificant(significantDigits: number = 6, format?: object, rounding?: Rounding): string { + return this.adjusted.toSignificant(significantDigits, format, rounding) + } + + public toFixed(decimalPlaces: number = 4, format?: object, rounding?: Rounding): string { + return this.adjusted.toFixed(decimalPlaces, format, rounding) + } +} diff --git a/packages/swap-sdk/src/entities/fractions/tokenAmount.ts b/packages/swap-sdk/src/entities/fractions/tokenAmount.ts new file mode 100644 index 000000000..96eba7f6a --- /dev/null +++ b/packages/swap-sdk/src/entities/fractions/tokenAmount.ts @@ -0,0 +1,26 @@ +import { CurrencyAmount } from './currencyAmount' +import { Token } from '../token' +import invariant from 'tiny-invariant' +import JSBI from 'jsbi' + +import { BigintIsh } from '../../constants' + +export class TokenAmount extends CurrencyAmount { + public readonly token: Token + + // amount _must_ be raw, i.e. in the native representation + public constructor(token: Token, amount: BigintIsh) { + super(token, amount) + this.token = token + } + + public add(other: TokenAmount): TokenAmount { + invariant(this.token.equals(other.token), 'TOKEN') + return new TokenAmount(this.token, JSBI.add(this.raw, other.raw)) + } + + public subtract(other: TokenAmount): TokenAmount { + invariant(this.token.equals(other.token), 'TOKEN') + return new TokenAmount(this.token, JSBI.subtract(this.raw, other.raw)) + } +} diff --git a/packages/swap-sdk/src/entities/index.ts b/packages/swap-sdk/src/entities/index.ts new file mode 100644 index 000000000..c217ba508 --- /dev/null +++ b/packages/swap-sdk/src/entities/index.ts @@ -0,0 +1,7 @@ +export * from './token' +export * from './pair' +export * from './route' +export * from './trade' +export * from './currency' + +export * from './fractions' diff --git a/packages/swap-sdk/src/entities/pair.ts b/packages/swap-sdk/src/entities/pair.ts new file mode 100644 index 000000000..147e0f32f --- /dev/null +++ b/packages/swap-sdk/src/entities/pair.ts @@ -0,0 +1,229 @@ +import { Price } from './fractions/price' +import { TokenAmount } from './fractions/tokenAmount' +import invariant from 'tiny-invariant' +import JSBI from 'jsbi' +import { pack, keccak256 } from '@ethersproject/solidity' +import { getCreate2Address } from '@ethersproject/address' + +import { + BigintIsh, + FACTORY_ADDRESS_MAP, + INIT_CODE_HASH_MAP, + MINIMUM_LIQUIDITY, + ZERO, + ONE, + FIVE, + FEES_NUMERATOR, + FEES_DENOMINATOR, + ChainId, +} from '../constants' +import { sqrt, parseBigintIsh } from '../utils' +import { InsufficientReservesError, InsufficientInputAmountError } from '../errors' +import { Token } from './token' + +let PAIR_ADDRESS_CACHE: { [key: string]: string } = {} + +const composeKey = (token0: Token, token1: Token) => `${token0.chainId}-${token0.address}-${token1.address}` + +export class Pair { + public readonly liquidityToken: Token + private readonly tokenAmounts: [TokenAmount, TokenAmount] + + public static getAddress(tokenA: Token, tokenB: Token): string { + const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA] // does safety checks + + const key = composeKey(token0, token1) + + if (PAIR_ADDRESS_CACHE?.[key] === undefined) { + PAIR_ADDRESS_CACHE = { + ...PAIR_ADDRESS_CACHE, + [key]: getCreate2Address( + FACTORY_ADDRESS_MAP[token0.chainId], + keccak256(['bytes'], [pack(['address', 'address'], [token0.address, token1.address])]), + INIT_CODE_HASH_MAP[token0.chainId] + ), + } + } + + return PAIR_ADDRESS_CACHE[key] + } + + public constructor(tokenAmountA: TokenAmount, tokenAmountB: TokenAmount) { + const tokenAmounts = tokenAmountA.token.sortsBefore(tokenAmountB.token) // does safety checks + ? [tokenAmountA, tokenAmountB] + : [tokenAmountB, tokenAmountA] + this.liquidityToken = new Token( + tokenAmounts[0].token.chainId, + Pair.getAddress(tokenAmounts[0].token, tokenAmounts[1].token), + 18, + 'Cake-LP', + 'Pancake LPs' + ) + this.tokenAmounts = tokenAmounts as [TokenAmount, TokenAmount] + } + + /** + * Returns true if the token is either token0 or token1 + * @param token to check + */ + public involvesToken(token: Token): boolean { + return token.equals(this.token0) || token.equals(this.token1) + } + + /** + * Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0 + */ + public get token0Price(): Price { + return new Price(this.token0, this.token1, this.tokenAmounts[0].raw, this.tokenAmounts[1].raw) + } + + /** + * Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1 + */ + public get token1Price(): Price { + return new Price(this.token1, this.token0, this.tokenAmounts[1].raw, this.tokenAmounts[0].raw) + } + + /** + * Return the price of the given token in terms of the other token in the pair. + * @param token token to return price of + */ + public priceOf(token: Token): Price { + invariant(this.involvesToken(token), 'TOKEN') + return token.equals(this.token0) ? this.token0Price : this.token1Price + } + + /** + * Returns the chain ID of the tokens in the pair. + */ + public get chainId(): ChainId { + return this.token0.chainId + } + + public get token0(): Token { + return this.tokenAmounts[0].token + } + + public get token1(): Token { + return this.tokenAmounts[1].token + } + + public get reserve0(): TokenAmount { + return this.tokenAmounts[0] + } + + public get reserve1(): TokenAmount { + return this.tokenAmounts[1] + } + + public reserveOf(token: Token): TokenAmount { + invariant(this.involvesToken(token), 'TOKEN') + return token.equals(this.token0) ? this.reserve0 : this.reserve1 + } + + public getOutputAmount(inputAmount: TokenAmount): [TokenAmount, Pair] { + invariant(this.involvesToken(inputAmount.token), 'TOKEN') + if (JSBI.equal(this.reserve0.raw, ZERO) || JSBI.equal(this.reserve1.raw, ZERO)) { + throw new InsufficientReservesError() + } + const inputReserve = this.reserveOf(inputAmount.token) + const outputReserve = this.reserveOf(inputAmount.token.equals(this.token0) ? this.token1 : this.token0) + const inputAmountWithFee = JSBI.multiply(inputAmount.raw, FEES_NUMERATOR) + const numerator = JSBI.multiply(inputAmountWithFee, outputReserve.raw) + const denominator = JSBI.add(JSBI.multiply(inputReserve.raw, FEES_DENOMINATOR), inputAmountWithFee) + const outputAmount = new TokenAmount( + inputAmount.token.equals(this.token0) ? this.token1 : this.token0, + JSBI.divide(numerator, denominator) + ) + if (JSBI.equal(outputAmount.raw, ZERO)) { + throw new InsufficientInputAmountError() + } + return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))] + } + + public getInputAmount(outputAmount: TokenAmount): [TokenAmount, Pair] { + invariant(this.involvesToken(outputAmount.token), 'TOKEN') + if ( + JSBI.equal(this.reserve0.raw, ZERO) || + JSBI.equal(this.reserve1.raw, ZERO) || + JSBI.greaterThanOrEqual(outputAmount.raw, this.reserveOf(outputAmount.token).raw) + ) { + throw new InsufficientReservesError() + } + + const outputReserve = this.reserveOf(outputAmount.token) + const inputReserve = this.reserveOf(outputAmount.token.equals(this.token0) ? this.token1 : this.token0) + const numerator = JSBI.multiply(JSBI.multiply(inputReserve.raw, outputAmount.raw), FEES_DENOMINATOR) + const denominator = JSBI.multiply(JSBI.subtract(outputReserve.raw, outputAmount.raw), FEES_NUMERATOR) + const inputAmount = new TokenAmount( + outputAmount.token.equals(this.token0) ? this.token1 : this.token0, + JSBI.add(JSBI.divide(numerator, denominator), ONE) + ) + return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))] + } + + public getLiquidityMinted( + totalSupply: TokenAmount, + tokenAmountA: TokenAmount, + tokenAmountB: TokenAmount + ): TokenAmount { + invariant(totalSupply.token.equals(this.liquidityToken), 'LIQUIDITY') + const tokenAmounts = tokenAmountA.token.sortsBefore(tokenAmountB.token) // does safety checks + ? [tokenAmountA, tokenAmountB] + : [tokenAmountB, tokenAmountA] + invariant(tokenAmounts[0].token.equals(this.token0) && tokenAmounts[1].token.equals(this.token1), 'TOKEN') + + let liquidity: JSBI + if (JSBI.equal(totalSupply.raw, ZERO)) { + liquidity = JSBI.subtract(sqrt(JSBI.multiply(tokenAmounts[0].raw, tokenAmounts[1].raw)), MINIMUM_LIQUIDITY) + } else { + const amount0 = JSBI.divide(JSBI.multiply(tokenAmounts[0].raw, totalSupply.raw), this.reserve0.raw) + const amount1 = JSBI.divide(JSBI.multiply(tokenAmounts[1].raw, totalSupply.raw), this.reserve1.raw) + liquidity = JSBI.lessThanOrEqual(amount0, amount1) ? amount0 : amount1 + } + if (!JSBI.greaterThan(liquidity, ZERO)) { + throw new InsufficientInputAmountError() + } + return new TokenAmount(this.liquidityToken, liquidity) + } + + public getLiquidityValue( + token: Token, + totalSupply: TokenAmount, + liquidity: TokenAmount, + feeOn: boolean = false, + kLast?: BigintIsh + ): TokenAmount { + invariant(this.involvesToken(token), 'TOKEN') + invariant(totalSupply.token.equals(this.liquidityToken), 'TOTAL_SUPPLY') + invariant(liquidity.token.equals(this.liquidityToken), 'LIQUIDITY') + invariant(JSBI.lessThanOrEqual(liquidity.raw, totalSupply.raw), 'LIQUIDITY') + + let totalSupplyAdjusted: TokenAmount + if (!feeOn) { + totalSupplyAdjusted = totalSupply + } else { + invariant(!!kLast, 'K_LAST') + const kLastParsed = parseBigintIsh(kLast) + if (!JSBI.equal(kLastParsed, ZERO)) { + const rootK = sqrt(JSBI.multiply(this.reserve0.raw, this.reserve1.raw)) + const rootKLast = sqrt(kLastParsed) + if (JSBI.greaterThan(rootK, rootKLast)) { + const numerator = JSBI.multiply(totalSupply.raw, JSBI.subtract(rootK, rootKLast)) + const denominator = JSBI.add(JSBI.multiply(rootK, FIVE), rootKLast) + const feeLiquidity = JSBI.divide(numerator, denominator) + totalSupplyAdjusted = totalSupply.add(new TokenAmount(this.liquidityToken, feeLiquidity)) + } else { + totalSupplyAdjusted = totalSupply + } + } else { + totalSupplyAdjusted = totalSupply + } + } + + return new TokenAmount( + token, + JSBI.divide(JSBI.multiply(liquidity.raw, this.reserveOf(token).raw), totalSupplyAdjusted.raw) + ) + } +} diff --git a/packages/swap-sdk/src/entities/route.ts b/packages/swap-sdk/src/entities/route.ts new file mode 100644 index 000000000..e7d1e9e09 --- /dev/null +++ b/packages/swap-sdk/src/entities/route.ts @@ -0,0 +1,52 @@ +import { ChainId } from '../constants' +import invariant from 'tiny-invariant' + +import { Currency, ETHER } from './currency' +import { Token, WNATIVE } from './token' +import { Pair } from './pair' +import { Price } from './fractions/price' + +export class Route { + public readonly pairs: Pair[] + public readonly path: Token[] + public readonly input: Currency + public readonly output: Currency + public readonly midPrice: Price + + public constructor(pairs: Pair[], input: Currency, output?: Currency) { + invariant(pairs.length > 0, 'PAIRS') + invariant( + pairs.every((pair) => pair.chainId === pairs[0].chainId), + 'CHAIN_IDS' + ) + invariant( + (input instanceof Token && pairs[0].involvesToken(input)) || + (input === ETHER && pairs[0].involvesToken(WNATIVE[pairs[0].chainId])), + 'INPUT' + ) + invariant( + typeof output === 'undefined' || + (output instanceof Token && pairs[pairs.length - 1].involvesToken(output)) || + (output === ETHER && pairs[pairs.length - 1].involvesToken(WNATIVE[pairs[0].chainId])), + 'OUTPUT' + ) + + const path: Token[] = [input instanceof Token ? input : WNATIVE[pairs[0].chainId]] + for (const [i, pair] of pairs.entries()) { + const currentInput = path[i] + invariant(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), 'PATH') + const output = currentInput.equals(pair.token0) ? pair.token1 : pair.token0 + path.push(output) + } + + this.pairs = pairs + this.path = path + this.midPrice = Price.fromRoute(this) + this.input = input + this.output = output ?? path[path.length - 1] + } + + public get chainId(): ChainId { + return this.pairs[0].chainId + } +} diff --git a/packages/swap-sdk/src/entities/token.ts b/packages/swap-sdk/src/entities/token.ts new file mode 100644 index 000000000..13efe7c1a --- /dev/null +++ b/packages/swap-sdk/src/entities/token.ts @@ -0,0 +1,111 @@ +import invariant from 'tiny-invariant' +import { ChainId } from '../constants' +import { validateAndParseAddress } from '../utils' +import { Currency } from './currency' + +/** + * Represents an ERC20 token with a unique address and some metadata. + */ +export class Token extends Currency { + public readonly chainId: ChainId + public readonly address: string + public readonly projectLink?: string + + public constructor( + chainId: ChainId, + address: string, + decimals: number, + symbol?: string, + name?: string, + projectLink?: string + ) { + super(decimals, symbol, name) + this.chainId = chainId + this.address = validateAndParseAddress(address) + this.projectLink = projectLink + } + + /** + * Returns true if the two tokens are equivalent, i.e. have the same chainId and address. + * @param other other token to compare + */ + public equals(other: Token): boolean { + // 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 + */ + public sortsBefore(other: Token): boolean { + invariant(this.chainId === other.chainId, 'CHAIN_IDS') + invariant(this.address !== other.address, 'ADDRESSES') + return this.address.toLowerCase() < other.address.toLowerCase() + } +} + +/** + * Compares two currencies for equality + */ +export function currencyEquals(currencyA: Currency, currencyB: Currency): boolean { + 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 + } +} + +// export const WETH9 = { +// [ChainId.ETHEREUM]: new Token( +// ChainId.ETHEREUM, +// '0xc778417E063141139Fce010982780140Aa0cD5Ab', +// 18, +// 'WETH', +// 'Wrapped Ether', +// 'https://weth.io' +// ), +// [ChainId.RINKEBY]: new Token( +// ChainId.RINKEBY, +// '0xc778417E063141139Fce010982780140Aa0cD5Ab', +// 18, +// 'WETH', +// 'Wrapped Ether', +// 'https://weth.io' +// ) +// } + +export const WBNB = { + [ChainId.BSC]: new Token( + ChainId.BSC, + '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', + 18, + 'WBNB', + 'Wrapped BNB', + 'https://www.binance.org' + ), + [ChainId.BSC_TESTNET]: new Token( + ChainId.BSC_TESTNET, + '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd', + 18, + 'WBNB', + 'Wrapped BNB', + 'https://www.binance.org' + ), +} + +export const WNATIVE = { + // [ChainId.ETHEREUM]: WETH9[ChainId.ETHEREUM], + // [ChainId.RINKEBY]: WETH9[ChainId.RINKEBY], + [ChainId.BSC]: WBNB[ChainId.BSC], + [ChainId.BSC_TESTNET]: WBNB[ChainId.BSC_TESTNET], +} diff --git a/packages/swap-sdk/src/entities/trade.ts b/packages/swap-sdk/src/entities/trade.ts new file mode 100644 index 000000000..3f28c8c2d --- /dev/null +++ b/packages/swap-sdk/src/entities/trade.ts @@ -0,0 +1,411 @@ +import invariant from 'tiny-invariant' +import { InsufficientInputAmountError, InsufficientReservesError } from '..' + +import { ChainId, ONE, TradeType, ZERO } from '../constants' +import { sortedInsert } from '../utils' +import { Currency, ETHER } from './currency' +import { CurrencyAmount } from './fractions/currencyAmount' +import { Fraction } from './fractions/fraction' +import { Percent } from './fractions/percent' +import { Price } from './fractions/price' +import { TokenAmount } from './fractions/tokenAmount' +import { Pair } from './pair' +import { Route } from './route' +import { currencyEquals, Token, WNATIVE } from './token' + +/** + * Returns the percent difference between the mid price and the execution price, i.e. price impact. + * @param midPrice mid price before the trade + * @param inputAmount the input amount of the trade + * @param outputAmount the output amount of the trade + */ +function computePriceImpact(midPrice: Price, inputAmount: CurrencyAmount, outputAmount: CurrencyAmount): Percent { + const exactQuote = midPrice.raw.multiply(inputAmount.raw) + // calculate slippage := (exactQuote - outputAmount) / exactQuote + const slippage = exactQuote.subtract(outputAmount.raw).divide(exactQuote) + return new Percent(slippage.numerator, slippage.denominator) +} + +// minimal interface so the input output comparator may be shared across types +interface InputOutput { + readonly inputAmount: CurrencyAmount + readonly outputAmount: CurrencyAmount +} + +// comparator function that allows sorting trades by their output amounts, in decreasing order, and then input amounts +// in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first +export function inputOutputComparator(a: InputOutput, b: InputOutput): number { + // must have same input and output token for comparison + invariant(currencyEquals(a.inputAmount.currency, b.inputAmount.currency), 'INPUT_CURRENCY') + invariant(currencyEquals(a.outputAmount.currency, b.outputAmount.currency), 'OUTPUT_CURRENCY') + if (a.outputAmount.equalTo(b.outputAmount)) { + if (a.inputAmount.equalTo(b.inputAmount)) { + return 0 + } + // trade A requires less input than trade B, so A should come first + if (a.inputAmount.lessThan(b.inputAmount)) { + return -1 + } else { + return 1 + } + } else { + // tradeA has less output than trade B, so should come second + if (a.outputAmount.lessThan(b.outputAmount)) { + return 1 + } else { + return -1 + } + } +} + +// extension of the input output comparator that also considers other dimensions of the trade in ranking them +export function tradeComparator(a: Trade, b: Trade) { + const ioComp = inputOutputComparator(a, b) + if (ioComp !== 0) { + return ioComp + } + + // consider lowest slippage next, since these are less likely to fail + if (a.priceImpact.lessThan(b.priceImpact)) { + return -1 + } else if (a.priceImpact.greaterThan(b.priceImpact)) { + return 1 + } + + // finally consider the number of hops since each hop costs gas + return a.route.path.length - b.route.path.length +} + +export interface BestTradeOptions { + // how many results to return + maxNumResults?: number + // the maximum number of hops a trade should contain + maxHops?: number +} + +/** + * Given a currency amount and a chain ID, returns the equivalent representation as the token amount. + * In other words, if the currency is ETHER, returns the WETH token amount for the given chain. Otherwise, returns + * the input currency amount. + */ +function wrappedAmount(currencyAmount: CurrencyAmount, chainId: ChainId): TokenAmount { + if (currencyAmount instanceof TokenAmount) return currencyAmount + if (currencyAmount.currency === ETHER) return new TokenAmount(WNATIVE[chainId], currencyAmount.raw) + invariant(false, 'CURRENCY') +} + +function wrappedCurrency(currency: Currency, chainId: ChainId): Token { + if (currency instanceof Token) return currency + if (currency === ETHER) return WNATIVE[chainId] + invariant(false, 'CURRENCY') +} + +/** + * Represents a trade executed against a list of pairs. + * Does not account for slippage, i.e. trades that front run this trade and move the price. + */ +export class Trade { + /** + * The route of the trade, i.e. which pairs the trade goes through. + */ + public readonly route: Route + /** + * The type of the trade, either exact in or exact out. + */ + public readonly tradeType: TradeType + /** + * The input amount for the trade assuming no slippage. + */ + public readonly inputAmount: CurrencyAmount + /** + * The output amount for the trade assuming no slippage. + */ + public readonly outputAmount: CurrencyAmount + /** + * The price expressed in terms of output amount/input amount. + */ + public readonly executionPrice: Price + /** + * The mid price after the trade executes assuming no slippage. + */ + public readonly nextMidPrice: Price + /** + * The percent difference between the mid price before the trade and the trade execution price. + */ + public readonly priceImpact: Percent + + /** + * Constructs an exact in trade with the given amount in and route + * @param route route of the exact in trade + * @param amountIn the amount being passed in + */ + public static exactIn(route: Route, amountIn: CurrencyAmount): Trade { + return new Trade(route, amountIn, TradeType.EXACT_INPUT) + } + + /** + * Constructs an exact out trade with the given amount out and route + * @param route route of the exact out trade + * @param amountOut the amount returned by the trade + */ + public static exactOut(route: Route, amountOut: CurrencyAmount): Trade { + return new Trade(route, amountOut, TradeType.EXACT_OUTPUT) + } + + public constructor(route: Route, amount: CurrencyAmount, tradeType: TradeType) { + const amounts: TokenAmount[] = new Array(route.path.length) + const nextPairs: Pair[] = new Array(route.pairs.length) + if (tradeType === TradeType.EXACT_INPUT) { + invariant(currencyEquals(amount.currency, route.input), 'INPUT') + amounts[0] = wrappedAmount(amount, route.chainId) + for (let i = 0; i < route.path.length - 1; i++) { + const pair = route.pairs[i] + const [outputAmount, nextPair] = pair.getOutputAmount(amounts[i]) + amounts[i + 1] = outputAmount + nextPairs[i] = nextPair + } + } else { + invariant(currencyEquals(amount.currency, route.output), 'OUTPUT') + amounts[amounts.length - 1] = wrappedAmount(amount, route.chainId) + for (let i = route.path.length - 1; i > 0; i--) { + const pair = route.pairs[i - 1] + const [inputAmount, nextPair] = pair.getInputAmount(amounts[i]) + amounts[i - 1] = inputAmount + nextPairs[i - 1] = nextPair + } + } + + this.route = route + this.tradeType = tradeType + this.inputAmount = + tradeType === TradeType.EXACT_INPUT + ? amount + : route.input === ETHER + ? CurrencyAmount.ether(amounts[0].raw) + : amounts[0] + this.outputAmount = + tradeType === TradeType.EXACT_OUTPUT + ? amount + : route.output === ETHER + ? CurrencyAmount.ether(amounts[amounts.length - 1].raw) + : amounts[amounts.length - 1] + this.executionPrice = new Price( + this.inputAmount.currency, + this.outputAmount.currency, + this.inputAmount.raw, + this.outputAmount.raw + ) + this.nextMidPrice = Price.fromRoute(new Route(nextPairs, route.input)) + this.priceImpact = computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount) + } + + /** + * Get the minimum amount that must be received from this trade for the given slippage tolerance + * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade + */ + public minimumAmountOut(slippageTolerance: Percent): CurrencyAmount { + invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE') + if (this.tradeType === TradeType.EXACT_OUTPUT) { + return this.outputAmount + } else { + const slippageAdjustedAmountOut = new Fraction(ONE) + .add(slippageTolerance) + .invert() + .multiply(this.outputAmount.raw).quotient + return this.outputAmount instanceof TokenAmount + ? new TokenAmount(this.outputAmount.token, slippageAdjustedAmountOut) + : CurrencyAmount.ether(slippageAdjustedAmountOut) + } + } + + /** + * Get the maximum amount in that can be spent via this trade for the given slippage tolerance + * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade + */ + public maximumAmountIn(slippageTolerance: Percent): CurrencyAmount { + invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE') + if (this.tradeType === TradeType.EXACT_INPUT) { + return this.inputAmount + } else { + const slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(this.inputAmount.raw).quotient + return this.inputAmount instanceof TokenAmount + ? new TokenAmount(this.inputAmount.token, slippageAdjustedAmountIn) + : CurrencyAmount.ether(slippageAdjustedAmountIn) + } + } + + /** + * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token + * amount to an output token, making at most `maxHops` hops. + * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting + * the amount in among multiple routes. + * @param pairs the pairs to consider in finding the best trade + * @param currencyAmountIn exact amount of input currency to spend + * @param currencyOut the desired currency out + * @param maxNumResults maximum number of results to return + * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair + * @param currentPairs used in recursion; the current list of pairs + * @param originalAmountIn used in recursion; the original value of the currencyAmountIn parameter + * @param bestTrades used in recursion; the current list of best trades + */ + public static bestTradeExactIn( + pairs: Pair[], + currencyAmountIn: CurrencyAmount, + currencyOut: Currency, + { maxNumResults = 3, maxHops = 3 }: BestTradeOptions = {}, + // used in recursion. + currentPairs: Pair[] = [], + originalAmountIn: CurrencyAmount = currencyAmountIn, + bestTrades: Trade[] = [] + ): Trade[] { + invariant(pairs.length > 0, 'PAIRS') + invariant(maxHops > 0, 'MAX_HOPS') + invariant(originalAmountIn === currencyAmountIn || currentPairs.length > 0, 'INVALID_RECURSION') + const chainId: ChainId | undefined = + currencyAmountIn instanceof TokenAmount + ? currencyAmountIn.token.chainId + : currencyOut instanceof Token + ? currencyOut.chainId + : undefined + invariant(chainId !== undefined, 'CHAIN_ID') + + const amountIn = wrappedAmount(currencyAmountIn, chainId) + const tokenOut = wrappedCurrency(currencyOut, chainId) + for (let i = 0; i < pairs.length; i++) { + const pair = pairs[i] + // pair irrelevant + if (!pair.token0.equals(amountIn.token) && !pair.token1.equals(amountIn.token)) continue + if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue + + let amountOut: TokenAmount + try { + ;[amountOut] = pair.getOutputAmount(amountIn) + } catch (error) { + // input too low + if ((error as InsufficientInputAmountError).isInsufficientInputAmountError) { + continue + } + throw error + } + // we have arrived at the output token, so this is the final trade of one of the paths + if (amountOut.token.equals(tokenOut)) { + sortedInsert( + bestTrades, + new Trade( + new Route([...currentPairs, pair], originalAmountIn.currency, currencyOut), + originalAmountIn, + TradeType.EXACT_INPUT + ), + maxNumResults, + tradeComparator + ) + } else if (maxHops > 1 && pairs.length > 1) { + const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length)) + + // otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops + Trade.bestTradeExactIn( + pairsExcludingThisPair, + amountOut, + currencyOut, + { + maxNumResults, + maxHops: maxHops - 1, + }, + [...currentPairs, pair], + originalAmountIn, + bestTrades + ) + } + } + + return bestTrades + } + + /** + * similar to the above method but instead targets a fixed output amount + * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token + * to an output token amount, making at most `maxHops` hops + * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting + * the amount in among multiple routes. + * @param pairs the pairs to consider in finding the best trade + * @param currencyIn the currency to spend + * @param currencyAmountOut the exact amount of currency out + * @param maxNumResults maximum number of results to return + * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair + * @param currentPairs used in recursion; the current list of pairs + * @param originalAmountOut used in recursion; the original value of the currencyAmountOut parameter + * @param bestTrades used in recursion; the current list of best trades + */ + public static bestTradeExactOut( + pairs: Pair[], + currencyIn: Currency, + currencyAmountOut: CurrencyAmount, + { maxNumResults = 3, maxHops = 3 }: BestTradeOptions = {}, + // used in recursion. + currentPairs: Pair[] = [], + originalAmountOut: CurrencyAmount = currencyAmountOut, + bestTrades: Trade[] = [] + ): Trade[] { + invariant(pairs.length > 0, 'PAIRS') + invariant(maxHops > 0, 'MAX_HOPS') + invariant(originalAmountOut === currencyAmountOut || currentPairs.length > 0, 'INVALID_RECURSION') + const chainId: ChainId | undefined = + currencyAmountOut instanceof TokenAmount + ? currencyAmountOut.token.chainId + : currencyIn instanceof Token + ? currencyIn.chainId + : undefined + invariant(chainId !== undefined, 'CHAIN_ID') + + const amountOut = wrappedAmount(currencyAmountOut, chainId) + const tokenIn = wrappedCurrency(currencyIn, chainId) + for (let i = 0; i < pairs.length; i++) { + const pair = pairs[i] + // pair irrelevant + if (!pair.token0.equals(amountOut.token) && !pair.token1.equals(amountOut.token)) continue + if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue + + let amountIn: TokenAmount + try { + ;[amountIn] = pair.getInputAmount(amountOut) + } catch (error) { + // not enough liquidity in this pair + if ((error as InsufficientReservesError).isInsufficientReservesError) { + continue + } + throw error + } + // we have arrived at the input token, so this is the first trade of one of the paths + if (amountIn.token.equals(tokenIn)) { + sortedInsert( + bestTrades, + new Trade( + new Route([pair, ...currentPairs], currencyIn, originalAmountOut.currency), + originalAmountOut, + TradeType.EXACT_OUTPUT + ), + maxNumResults, + tradeComparator + ) + } else if (maxHops > 1 && pairs.length > 1) { + const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length)) + + // otherwise, consider all the other paths that arrive at this token as long as we have not exceeded maxHops + Trade.bestTradeExactOut( + pairsExcludingThisPair, + currencyIn, + amountIn, + { + maxNumResults, + maxHops: maxHops - 1, + }, + [pair, ...currentPairs], + originalAmountOut, + bestTrades + ) + } + } + + return bestTrades + } +} diff --git a/packages/swap-sdk/src/errors.ts b/packages/swap-sdk/src/errors.ts new file mode 100644 index 000000000..7d351bc19 --- /dev/null +++ b/packages/swap-sdk/src/errors.ts @@ -0,0 +1,30 @@ +// see https://stackoverflow.com/a/41102306 +const 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. + */ +export class InsufficientReservesError extends Error { + public readonly isInsufficientReservesError: true = true + + public constructor() { + super() + this.name = this.constructor.name + if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype) + } +} + +/** + * 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. + */ +export class InsufficientInputAmountError extends Error { + public readonly isInsufficientInputAmountError: true = true + + public constructor() { + super() + this.name = this.constructor.name + if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype) + } +} diff --git a/packages/swap-sdk/src/fetcher.ts b/packages/swap-sdk/src/fetcher.ts new file mode 100644 index 000000000..bdf4b9831 --- /dev/null +++ b/packages/swap-sdk/src/fetcher.ts @@ -0,0 +1,75 @@ +import { Contract } from '@ethersproject/contracts' +import { getNetwork } from '@ethersproject/networks' +import { getDefaultProvider } from '@ethersproject/providers' +import { TokenAmount } from './entities/fractions/tokenAmount' +import { Pair } from './entities/pair' +import IPancakePair from './abis/IPancakePair.json' +import invariant from 'tiny-invariant' +import ERC20 from './abis/ERC20.json' +import { ChainId } from './constants' +import { Token } from './entities/token' + +let TOKEN_DECIMALS_CACHE: { [chainId: number]: { [address: string]: number } } = { + [ChainId.BSC]: { + '0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A': 9, // DGD + }, +} + +/** + * Contains methods for constructing instances of pairs and tokens from on-chain data. + */ +export abstract class Fetcher { + /** + * Cannot be constructed. + */ + private constructor() {} + + /** + * Fetch information for a given token on the given chain, using the given ethers provider. + * @param chainId chain of the token + * @param address address of the token on the chain + * @param provider provider used to fetch the token + * @param symbol optional symbol of the token + * @param name optional name of the token + */ + public static async fetchTokenData( + chainId: ChainId, + address: string, + provider = getDefaultProvider(getNetwork(chainId)), + symbol?: string, + name?: string + ): Promise { + const parsedDecimals = + typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === 'number' + ? TOKEN_DECIMALS_CACHE[chainId][address] + : await new Contract(address, ERC20, provider).decimals().then((decimals: number): number => { + TOKEN_DECIMALS_CACHE = { + ...TOKEN_DECIMALS_CACHE, + [chainId]: { + ...TOKEN_DECIMALS_CACHE?.[chainId], + [address]: decimals, + }, + } + return decimals + }) + return new Token(chainId, address, parsedDecimals, symbol, name) + } + + /** + * Fetches information about a pair and constructs a pair from the given two tokens. + * @param tokenA first token + * @param tokenB second token + * @param provider the provider to use to fetch the data + */ + public static async fetchPairData( + tokenA: Token, + tokenB: Token, + provider = getDefaultProvider(getNetwork(tokenA.chainId)) + ): Promise { + invariant(tokenA.chainId === tokenB.chainId, 'CHAIN_ID') + const address = Pair.getAddress(tokenA, tokenB) + const [reserves0, reserves1] = await new Contract(address, IPancakePair, provider).getReserves() + const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0] + return new Pair(new TokenAmount(tokenA, balances[0]), new TokenAmount(tokenB, balances[1])) + } +} diff --git a/packages/swap-sdk/src/index.ts b/packages/swap-sdk/src/index.ts new file mode 100644 index 000000000..1589f6bae --- /dev/null +++ b/packages/swap-sdk/src/index.ts @@ -0,0 +1,9 @@ +import JSBI from 'jsbi' +export { JSBI } + +export * from './constants' + +export * from './errors' +export * from './entities' +export * from './router' +export * from './fetcher' diff --git a/packages/swap-sdk/src/router.ts b/packages/swap-sdk/src/router.ts new file mode 100644 index 000000000..aae472d00 --- /dev/null +++ b/packages/swap-sdk/src/router.ts @@ -0,0 +1,144 @@ +import { TradeType } from './constants' +import invariant from 'tiny-invariant' +import { validateAndParseAddress } from './utils' +import { CurrencyAmount, ETHER, Percent, Trade } from './entities' + +/** + * Options for producing the arguments to send call to the router. + */ +export interface TradeOptions { + /** + * How much the execution price is allowed to move unfavorably from the trade execution price. + */ + allowedSlippage: Percent + /** + * How long the swap is valid until it expires, in seconds. + * This will be used to produce a `deadline` parameter which is computed from when the swap call parameters + * are generated. + */ + ttl: number + /** + * The account that should receive the output of the swap. + */ + recipient: string + + /** + * Whether any of the tokens in the path are fee on transfer tokens, which should be handled with special methods + */ + feeOnTransfer?: boolean +} + +export interface TradeOptionsDeadline extends Omit { + /** + * When the transaction expires. + * This is an atlernate to specifying the ttl, for when you do not want to use local time. + */ + deadline: number +} + +/** + * The parameters to use in the call to the Pancake Router to execute a trade. + */ +export interface SwapParameters { + /** + * The method to call on the Pancake Router. + */ + methodName: string + /** + * The arguments to pass to the method, all hex encoded. + */ + args: (string | string[])[] + /** + * The amount of wei to send in hex. + */ + value: string +} + +function toHex(currencyAmount: CurrencyAmount) { + return `0x${currencyAmount.raw.toString(16)}` +} + +const ZERO_HEX = '0x0' + +/** + * Represents the Pancake Router, and has static methods for helping execute trades. + */ +export abstract class Router { + /** + * Cannot be constructed. + */ + private constructor() {} + /** + * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade. + * @param trade to produce call parameters for + * @param options options for the call parameters + */ + public static swapCallParameters(trade: Trade, options: TradeOptions | TradeOptionsDeadline): SwapParameters { + const etherIn = trade.inputAmount.currency === ETHER + const etherOut = trade.outputAmount.currency === ETHER + // the router does not support both ether in and out + invariant(!(etherIn && etherOut), 'ETHER_IN_OUT') + invariant(!('ttl' in options) || options.ttl > 0, 'TTL') + + const to: string = validateAndParseAddress(options.recipient) + const amountIn: string = toHex(trade.maximumAmountIn(options.allowedSlippage)) + const amountOut: string = toHex(trade.minimumAmountOut(options.allowedSlippage)) + const path: string[] = trade.route.path.map((token) => token.address) + const deadline = + 'ttl' in options + ? `0x${(Math.floor(new Date().getTime() / 1000) + options.ttl).toString(16)}` + : `0x${options.deadline.toString(16)}` + + const useFeeOnTransfer = Boolean(options.feeOnTransfer) + + let methodName: string + let args: (string | string[])[] + let value: string + switch (trade.tradeType) { + case TradeType.EXACT_INPUT: + if (etherIn) { + methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens' + // (uint amountOutMin, address[] calldata path, address to, uint deadline) + args = [amountOut, path, to, deadline] + value = amountIn + } else if (etherOut) { + methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH' + // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + args = [amountIn, amountOut, path, to, deadline] + value = ZERO_HEX + } else { + methodName = useFeeOnTransfer + ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens' + : 'swapExactTokensForTokens' + // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) + args = [amountIn, amountOut, path, to, deadline] + value = ZERO_HEX + } + break + case TradeType.EXACT_OUTPUT: + invariant(!useFeeOnTransfer, 'EXACT_OUT_FOT') + if (etherIn) { + methodName = 'swapETHForExactTokens' + // (uint amountOut, address[] calldata path, address to, uint deadline) + args = [amountOut, path, to, deadline] + value = amountIn + } else if (etherOut) { + methodName = 'swapTokensForExactETH' + // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + args = [amountOut, amountIn, path, to, deadline] + value = ZERO_HEX + } else { + methodName = 'swapTokensForExactTokens' + // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) + args = [amountOut, amountIn, path, to, deadline] + value = ZERO_HEX + } + break + } + return { + methodName, + args, + value, + } + } +} diff --git a/packages/swap-sdk/src/utils.ts b/packages/swap-sdk/src/utils.ts new file mode 100644 index 000000000..da9623dfe --- /dev/null +++ b/packages/swap-sdk/src/utils.ts @@ -0,0 +1,78 @@ +import invariant from 'tiny-invariant' +import warning from 'tiny-warning' +import JSBI from 'jsbi' +import { getAddress } from '@ethersproject/address' + +import { BigintIsh, ZERO, ONE, TWO, THREE, SolidityType, SOLIDITY_TYPE_MAXIMA } from './constants' + +export function validateSolidityTypeInstance(value: JSBI, solidityType: SolidityType): void { + invariant(JSBI.greaterThanOrEqual(value, ZERO), `${value} is not a ${solidityType}.`) + invariant(JSBI.lessThanOrEqual(value, SOLIDITY_TYPE_MAXIMA[solidityType]), `${value} is not a ${solidityType}.`) +} + +// warns if addresses are not checksummed +export function validateAndParseAddress(address: string): string { + try { + const checksummedAddress = getAddress(address) + warning(address === checksummedAddress, `${address} is not checksummed.`) + return checksummedAddress + } catch (error) { + invariant(false, `${address} is not a valid address.`) + } +} + +export function parseBigintIsh(bigintIsh: BigintIsh): JSBI { + return bigintIsh instanceof JSBI ? bigintIsh : JSBI.BigInt(bigintIsh) +} + +// mock the on-chain sqrt function +export function sqrt(y: JSBI): JSBI { + validateSolidityTypeInstance(y, SolidityType.uint256) + let z: JSBI = ZERO + let x: JSBI + 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 +export function sortedInsert(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null { + invariant(maxSize > 0, 'MAX_SIZE_ZERO') + // this is an invariant because the interface cannot return multiple removed items if items.length exceeds maxSize + invariant(items.length <= maxSize, 'ITEMS_SIZE') + + // short circuit first item add + if (items.length === 0) { + items.push(add) + return null + } else { + const 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 + } + + let lo = 0, + hi = items.length + + while (lo < hi) { + const 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 + } +} diff --git a/packages/swap-sdk/test/bytecode b/packages/swap-sdk/test/bytecode new file mode 100644 index 000000000..7031f95eb --- /dev/null +++ b/packages/swap-sdk/test/bytecode @@ -0,0 +1 @@ +60806040526001600c5534801561001557600080fd5b5060004690506040518080613bfa60529139605201905060405180910390206040518060400160405280600b81526020017f50616e63616b65204c5073000000000000000000000000000000000000000000815250805190602001206040518060400160405280600181526020017f3100000000000000000000000000000000000000000000000000000000000000815250805190602001208330604051602001808681526020018581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200195505050505050604051602081830303815290604052805190602001206003819055505033600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550613a85806101756000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146108c4578063d505accf1461090e578063dd62ed3e146109a7578063fff6cae914610a1f576101a9565b8063ba9a7a5614610818578063bc25cf7714610836578063c45a01551461087a576101a9565b80637ecebe00116100d35780637ecebe001461067857806389afcb44146106d057806395d89b411461072f578063a9059cbb146107b2576101a9565b80636a627842146105aa57806370a08231146106025780637464fc3d1461065a576101a9565b806323b872dd116101665780633644e515116101405780633644e515146104ec578063485cc9551461050a5780635909c0d51461056e5780635a3d54931461058c576101a9565b806323b872dd1461042457806330adf81f146104aa578063313ce567146104c8576101a9565b8063022c0d9f146101ae57806306fdde031461025b5780630902f1ac146102de578063095ea7b3146103565780630dfe1681146103bc57806318160ddd14610406575b600080fd5b610259600480360360808110156101c457600080fd5b810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561021557600080fd5b82018360208201111561022757600080fd5b8035906020019184600183028401116401000000008311171561024957600080fd5b9091929391929390505050610a29565b005b610263611234565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102a3578082015181840152602081019050610288565b50505050905090810190601f1680156102d05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102e661126d565b60405180846dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff168152602001836dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff1681526020018263ffffffff1663ffffffff168152602001935050505060405180910390f35b6103a26004803603604081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112ca565b604051808215151515815260200191505060405180910390f35b6103c46112e1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61040e611307565b6040518082815260200191505060405180910390f35b6104906004803603606081101561043a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061130d565b604051808215151515815260200191505060405180910390f35b6104b26114d8565b6040518082815260200191505060405180910390f35b6104d06114ff565b604051808260ff1660ff16815260200191505060405180910390f35b6104f4611504565b6040518082815260200191505060405180910390f35b61056c6004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061150a565b005b610576611653565b6040518082815260200191505060405180910390f35b610594611659565b6040518082815260200191505060405180910390f35b6105ec600480360360208110156105c057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061165f565b6040518082815260200191505060405180910390f35b6106446004803603602081101561061857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b10565b6040518082815260200191505060405180910390f35b610662611b28565b6040518082815260200191505060405180910390f35b6106ba6004803603602081101561068e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b2e565b6040518082815260200191505060405180910390f35b610712600480360360208110156106e657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b46565b604051808381526020018281526020019250505060405180910390f35b610737612133565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561077757808201518184015260208101905061075c565b50505050905090810190601f1680156107a45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6107fe600480360360408110156107c857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061216c565b604051808215151515815260200191505060405180910390f35b610820612183565b6040518082815260200191505060405180910390f35b6108786004803603602081101561084c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612189565b005b610882612464565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6108cc61248a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6109a5600480360360e081101561092457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803560ff16906020019092919080359060200190929190803590602001909291905050506124b0565b005b610a09600480360360408110156109bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506127f4565b6040518082815260200191505060405180910390f35b610a27612819565b005b6001600c5414610aa1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f50616e63616b653a204c4f434b4544000000000000000000000000000000000081525060200191505060405180910390fd5b6000600c819055506000851180610ab85750600084115b610b0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180613a086023913960400191505060405180910390fd5b600080610b1861126d565b5091509150816dffffffffffffffffffffffffffff1687108015610b4b5750806dffffffffffffffffffffffffffff1686105b610bbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f50616e63616b653a20494e53554646494349454e545f4c49515549444954590081525060200191505060405180910390fd5b6000806000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508173ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614158015610c7657508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b610ce8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f50616e63616b653a20494e56414c49445f544f0000000000000000000000000081525060200191505060405180910390fd5b60008b1115610cfd57610cfc828a8d612a99565b5b60008a1115610d1257610d11818a8c612a99565b5b6000888890501115610dfa578873ffffffffffffffffffffffffffffffffffffffff166384800812338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b158015610de157600080fd5b505af1158015610df5573d6000803e3d6000fd5b505050505b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610e7757600080fd5b505afa158015610e8b573d6000803e3d6000fd5b505050506040513d6020811015610ea157600080fd5b810190808051906020019092919050505093508073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610f3157600080fd5b505afa158015610f45573d6000803e3d6000fd5b505050506040513d6020811015610f5b57600080fd5b810190808051906020019092919050505092505050600089856dffffffffffffffffffffffffffff16038311610f92576000610fa8565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610fcc576000610fe2565b89856dffffffffffffffffffffffffffff160383035b90506000821180610ff35750600081115b611048576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806139c06022913960400191505060405180910390fd5b6000611084611061601985612ce690919063ffffffff16565b61107661271088612ce690919063ffffffff16565b612d7b90919063ffffffff16565b905060006110c261109f601985612ce690919063ffffffff16565b6110b461271088612ce690919063ffffffff16565b612d7b90919063ffffffff16565b905061110d6305f5e1006110ff896dffffffffffffffffffffffffffff168b6dffffffffffffffffffffffffffff16612ce690919063ffffffff16565b612ce690919063ffffffff16565b6111208284612ce690919063ffffffff16565b1015611194576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f50616e63616b653a204b0000000000000000000000000000000000000000000081525060200191505060405180910390fd5b50506111a284848888612dfe565b8873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d82284848f8f6040518085815260200184815260200183815260200182815260200194505050505060405180910390a35050505050506001600c819055505050505050565b6040518060400160405280600b81526020017f50616e63616b65204c507300000000000000000000000000000000000000000081525081565b6000806000600860009054906101000a90046dffffffffffffffffffffffffffff1692506008600e9054906101000a90046dffffffffffffffffffffffffffff1691506008601c9054906101000a900463ffffffff169050909192565b60006112d733848461317c565b6001905092915050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146114c25761144182600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d7b90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6114cd848484613267565b600190509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960001b81565b601281565b60035481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f50616e63616b653a20464f5242494444454e000000000000000000000000000081525060200191505060405180910390fd5b81600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60095481565b600a5481565b60006001600c54146116d9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f50616e63616b653a204c4f434b4544000000000000000000000000000000000081525060200191505060405180910390fd5b6000600c819055506000806116ec61126d565b50915091506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561179257600080fd5b505afa1580156117a6573d6000803e3d6000fd5b505050506040513d60208110156117bc57600080fd5b810190808051906020019092919050505090506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561187057600080fd5b505afa158015611884573d6000803e3d6000fd5b505050506040513d602081101561189a57600080fd5b8101908080519060200190929190505050905060006118d2856dffffffffffffffffffffffffffff1684612d7b90919063ffffffff16565b905060006118f9856dffffffffffffffffffffffffffff1684612d7b90919063ffffffff16565b9050600061190787876133fb565b9050600080549050600081141561195b576119476103e86119396119348688612ce690919063ffffffff16565b613602565b612d7b90919063ffffffff16565b985061195660006103e8613664565b6119be565b6119bb886dffffffffffffffffffffffffffff166119828387612ce690919063ffffffff16565b8161198957fe5b04886dffffffffffffffffffffffffffff166119ae8487612ce690919063ffffffff16565b816119b557fe5b0461377e565b98505b60008911611a17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613a2b6026913960400191505060405180910390fd5b611a218a8a613664565b611a2d86868a8a612dfe565b8115611aa557611a9e6008600e9054906101000a90046dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff16600860009054906101000a90046dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff16612ce690919063ffffffff16565b600b819055505b3373ffffffffffffffffffffffffffffffffffffffff167f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f8585604051808381526020018281526020019250505060405180910390a250505050505050506001600c81905550919050565b60016020528060005260406000206000915090505481565b600b5481565b60046020528060005260406000206000915090505481565b6000806001600c5414611bc1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f50616e63616b653a204c4f434b4544000000000000000000000000000000000081525060200191505060405180910390fd5b6000600c81905550600080611bd461126d565b50915091506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611ca657600080fd5b505afa158015611cba573d6000803e3d6000fd5b505050506040513d6020811015611cd057600080fd5b8101908080519060200190929190505050905060008273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611d6257600080fd5b505afa158015611d76573d6000803e3d6000fd5b505050506040513d6020811015611d8c57600080fd5b810190808051906020019092919050505090506000600160003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000611def88886133fb565b905060008054905080611e0b8685612ce690919063ffffffff16565b81611e1257fe5b049a5080611e298585612ce690919063ffffffff16565b81611e3057fe5b04995060008b118015611e43575060008a115b611e98576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806139e26026913960400191505060405180910390fd5b611ea23084613797565b611ead878d8d612a99565b611eb8868d8c612a99565b8673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611f3557600080fd5b505afa158015611f49573d6000803e3d6000fd5b505050506040513d6020811015611f5f57600080fd5b810190808051906020019092919050505094508573ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611fef57600080fd5b505afa158015612003573d6000803e3d6000fd5b505050506040513d602081101561201957600080fd5b8101908080519060200190929190505050935061203885858b8b612dfe565b81156120b0576120a96008600e9054906101000a90046dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff16600860009054906101000a90046dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff16612ce690919063ffffffff16565b600b819055505b8b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d819364968d8d604051808381526020018281526020019250505060405180910390a35050505050505050506001600c81905550915091565b6040518060400160405280600781526020017f43616b652d4c500000000000000000000000000000000000000000000000000081525081565b6000612179338484613267565b6001905092915050565b6103e881565b6001600c5414612201576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f50616e63616b653a204c4f434b4544000000000000000000000000000000000081525060200191505060405180910390fd5b6000600c819055506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506123578284612352600860009054906101000a90046dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561230957600080fd5b505afa15801561231d573d6000803e3d6000fd5b505050506040513d602081101561233357600080fd5b8101908080519060200190929190505050612d7b90919063ffffffff16565b612a99565b61245781846124526008600e9054906101000a90046dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561240957600080fd5b505afa15801561241d573d6000803e3d6000fd5b505050506040513d602081101561243357600080fd5b8101908080519060200190929190505050612d7b90919063ffffffff16565b612a99565b50506001600c8190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b42841015612526576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f50616e63616b653a20455850495245440000000000000000000000000000000081525060200191505060405180910390fd5b60006003547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960001b898989600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190600101919050558a604051602001808781526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815260200196505050505050506040516020818303038152906040528051906020012060405160200180807f190100000000000000000000000000000000000000000000000000000000000081525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600060018286868660405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156126f8573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561276c57508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b6127de576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f50616e63616b653a20494e56414c49445f5349474e415455524500000000000081525060200191505060405180910390fd5b6127e989898961317c565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b6001600c5414612891576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f50616e63616b653a204c4f434b4544000000000000000000000000000000000081525060200191505060405180910390fd5b6000600c81905550612a8f600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561293b57600080fd5b505afa15801561294f573d6000803e3d6000fd5b505050506040513d602081101561296557600080fd5b8101908080519060200190929190505050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612a1557600080fd5b505afa158015612a29573d6000803e3d6000fd5b505050506040513d6020811015612a3f57600080fd5b8101908080519060200190929190505050600860009054906101000a90046dffffffffffffffffffffffffffff166008600e9054906101000a90046dffffffffffffffffffffffffffff16612dfe565b6001600c81905550565b600060608473ffffffffffffffffffffffffffffffffffffffff166040518060400160405280601981526020017f7472616e7366657228616464726573732c75696e743235362900000000000000815250805190602001208585604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b60208310612bc65780518252602082019150602081019050602083039250612ba3565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612c28576040519150601f19603f3d011682016040523d82523d6000602084013e612c2d565b606091505b5091509150818015612c6d5750600081511480612c6c5750808060200190516020811015612c5a57600080fd5b81019080805190602001909291905050505b5b612cdf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f50616e63616b653a205452414e534645525f4641494c4544000000000000000081525060200191505060405180910390fd5b5050505050565b600080821480612d035750828283850292508281612d0057fe5b04145b612d75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f64732d6d6174682d6d756c2d6f766572666c6f7700000000000000000000000081525060200191505060405180910390fd5b92915050565b6000828284039150811115612df8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f64732d6d6174682d7375622d756e646572666c6f77000000000000000000000081525060200191505060405180910390fd5b92915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6dffffffffffffffffffffffffffff168411158015612e6e57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6dffffffffffffffffffffffffffff168311155b612ee0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f50616e63616b653a204f564552464c4f5700000000000000000000000000000081525060200191505060405180910390fd5b60006401000000004281612ef057fe5b06905060006008601c9054906101000a900463ffffffff168203905060008163ffffffff16118015612f3357506000846dffffffffffffffffffffffffffff1614155b8015612f5057506000836dffffffffffffffffffffffffffff1614155b15613032578063ffffffff16612f9585612f69866138b1565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166138dc90919063ffffffff16565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16026009600082825401925050819055508063ffffffff1661300384612fd7876138b1565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166138dc90919063ffffffff16565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1602600a600082825401925050819055505b85600860006101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff160217905550846008600e6101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff160217905550816008601c6101000a81548163ffffffff021916908363ffffffff1602179055507f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1600860009054906101000a90046dffffffffffffffffffffffffffff166008600e9054906101000a90046dffffffffffffffffffffffffffff1660405180836dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff168152602001826dffffffffffffffffffffffffffff166dffffffffffffffffffffffffffff1681526020019250505060405180910390a1505050505050565b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b6132b981600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d7b90919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061334e81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461393c90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561346657600080fd5b505afa15801561347a573d6000803e3d6000fd5b505050506040513d602081101561349057600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141591506000600b54905082156135e857600081146135e3576000613528613523866dffffffffffffffffffffffffffff16886dffffffffffffffffffffffffffff16612ce690919063ffffffff16565b613602565b9050600061353583613602565b9050808211156135e057600061357b600861356d61355c8587612d7b90919063ffffffff16565b600054612ce690919063ffffffff16565b612ce690919063ffffffff16565b905060006135b8613596600885612ce690919063ffffffff16565b6135aa601187612ce690919063ffffffff16565b61393c90919063ffffffff16565b905060008183816135c557fe5b04905060008111156135dc576135db8782613664565b5b5050505b50505b6135fa565b600081146135f9576000600b819055505b5b505092915050565b6000600382111561365157819050600060016002848161361e57fe5b040190505b8181101561364b5780915060028182858161363a57fe5b04018161364357fe5b049050613623565b5061365f565b6000821461365e57600190505b5b919050565b6136798160005461393c90919063ffffffff16565b6000819055506136d181600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461393c90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600081831061378d578161378f565b825b905092915050565b6137e981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d7b90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061384181600054612d7b90919063ffffffff16565b600081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60006e010000000000000000000000000000826dffffffffffffffffffffffffffff16029050919050565b6000816dffffffffffffffffffffffffffff167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff168161393357fe5b04905092915050565b60008282840191508110156139b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f64732d6d6174682d6164642d6f766572666c6f7700000000000000000000000081525060200191505060405180910390fd5b9291505056fe50616e63616b653a20494e53554646494349454e545f494e5055545f414d4f554e5450616e63616b653a20494e53554646494349454e545f4c49515549444954595f4255524e454450616e63616b653a20494e53554646494349454e545f4f55545055545f414d4f554e5450616e63616b653a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158204c647542259e471353892c1bc85f3bd97626f8162e3134e910684c65f3f4f2ca64736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429 \ No newline at end of file diff --git a/packages/swap-sdk/test/constants.test.ts b/packages/swap-sdk/test/constants.test.ts new file mode 100644 index 000000000..da174026e --- /dev/null +++ b/packages/swap-sdk/test/constants.test.ts @@ -0,0 +1,18 @@ +import { INIT_CODE_HASH } from '../src/constants' +import fs from 'fs' +import path from 'path' +import { keccak256 } from '@ethersproject/solidity' + +const bytecode = fs.readFileSync(path.join(__dirname, './bytecode'), 'utf8') + +// this _could_ go in constants, except that it would cost every consumer of the sdk the CPU to compute the hash +// and load the JSON. +const COMPUTED_INIT_CODE_HASH = keccak256(['bytes'], [`0x${bytecode}`]) + +describe('constants', () => { + describe('INIT_CODE_HASH', () => { + it('matches computed bytecode hash', () => { + expect(COMPUTED_INIT_CODE_HASH).toEqual(INIT_CODE_HASH) + }) + }) +}) diff --git a/packages/swap-sdk/test/data.test.ts b/packages/swap-sdk/test/data.test.ts new file mode 100644 index 000000000..b556b348e --- /dev/null +++ b/packages/swap-sdk/test/data.test.ts @@ -0,0 +1,20 @@ +import { ChainId, WNATIVE, Token, Fetcher } from '../src' + +// TODO: replace the provider in these tests +describe.skip('data', () => { + it('Token', async () => { + const token = await Fetcher.fetchTokenData(ChainId.BSC, '0x6B175474E89094C44Da98b954EedeAC495271d0F') // DAI + expect(token.decimals).toEqual(18) + }) + + it('Token:CACHE', async () => { + const token = await Fetcher.fetchTokenData(ChainId.BSC, '0xE0B7927c4aF23765Cb51314A0E0521A9645F0E2A') // DGD + expect(token.decimals).toEqual(9) + }) + + it('Pair', async () => { + const token = new Token(ChainId.BSC_TESTNET, '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735', 18) // DAI + const pair = await Fetcher.fetchPairData(WNATIVE[ChainId.BSC_TESTNET], token) + expect(pair.liquidityToken.address).toEqual('0x8B22F85d0c844Cf793690F6D9DFE9F11Ddb35449') + }) +}) diff --git a/packages/swap-sdk/test/entities.test.ts b/packages/swap-sdk/test/entities.test.ts new file mode 100644 index 000000000..2f1bc41bb --- /dev/null +++ b/packages/swap-sdk/test/entities.test.ts @@ -0,0 +1,188 @@ +import invariant from 'tiny-invariant' +import JSBI from 'jsbi' +import { ChainId, WNATIVE as _WETH, TradeType, Rounding, Token, TokenAmount, Pair, Route, Trade } from '../src' + +const ADDRESSES = [ + '0x0000000000000000000000000000000000000001', + '0x0000000000000000000000000000000000000002', + '0x0000000000000000000000000000000000000003', +] +const CHAIN_ID = ChainId.BSC_TESTNET +const WETH = _WETH[ChainId.BSC_TESTNET] +const DECIMAL_PERMUTATIONS: [number, number, number][] = [ + [0, 0, 0], + [0, 9, 18], + [18, 18, 18], +] + +function decimalize(amount: number, decimals: number): JSBI { + return JSBI.multiply(JSBI.BigInt(amount), JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(decimals))) +} + +describe('entities', () => { + DECIMAL_PERMUTATIONS.forEach((decimals) => { + describe(`decimals permutation: ${decimals}`, () => { + let tokens: Token[] + it('Token', () => { + tokens = ADDRESSES.map((address, i) => new Token(CHAIN_ID, address, decimals[i])) + tokens.forEach((token, i) => { + expect(token.chainId).toEqual(CHAIN_ID) + expect(token.address).toEqual(ADDRESSES[i]) + expect(token.decimals).toEqual(decimals[i]) + }) + }) + + let pairs: Pair[] + it('Pair', () => { + pairs = [ + new Pair( + new TokenAmount(tokens[0], decimalize(1, tokens[0].decimals)), + new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)) + ), + new Pair( + new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)), + new TokenAmount(tokens[2], decimalize(1, tokens[2].decimals)) + ), + new Pair( + new TokenAmount(tokens[2], decimalize(1, tokens[2].decimals)), + new TokenAmount(WETH, decimalize(1234, WETH.decimals)) + ), + ] + }) + + let route: Route + it('Route', () => { + route = new Route(pairs, tokens[0]) + expect(route.pairs).toEqual(pairs) + expect(route.path).toEqual(tokens.concat([WETH])) + expect(route.input).toEqual(tokens[0]) + expect(route.output).toEqual(WETH) + }) + + it('Price:Route.midPrice', () => { + invariant(route.input instanceof Token) + invariant(route.output instanceof Token) + expect(route.midPrice.quote(new TokenAmount(route.input, decimalize(1, route.input.decimals)))).toEqual( + new TokenAmount(route.output, decimalize(1234, route.output.decimals)) + ) + expect( + route.midPrice.invert().quote(new TokenAmount(route.output, decimalize(1234, route.output.decimals))) + ).toEqual(new TokenAmount(route.input, decimalize(1, route.input.decimals))) + + expect(route.midPrice.toSignificant(1)).toEqual('1000') + expect(route.midPrice.toSignificant(2)).toEqual('1200') + expect(route.midPrice.toSignificant(3)).toEqual('1230') + expect(route.midPrice.toSignificant(4)).toEqual('1234') + expect(route.midPrice.toSignificant(5)).toEqual('1234') + expect(route.midPrice.toSignificant(5, { groupSeparator: ',' })).toEqual('1,234') + expect(route.midPrice.invert().toSignificant(1)).toEqual('0.0008') + expect(route.midPrice.invert().toSignificant(2)).toEqual('0.00081') + expect(route.midPrice.invert().toSignificant(3)).toEqual('0.00081') + expect(route.midPrice.invert().toSignificant(4)).toEqual('0.0008104') + expect(route.midPrice.invert().toSignificant(4, undefined, Rounding.ROUND_DOWN)).toEqual('0.0008103') + expect(route.midPrice.invert().toSignificant(5)).toEqual('0.00081037') + + expect(route.midPrice.toFixed(0)).toEqual('1234') + expect(route.midPrice.toFixed(1)).toEqual('1234.0') + expect(route.midPrice.toFixed(2)).toEqual('1234.00') + expect(route.midPrice.toFixed(2, { groupSeparator: ',' })).toEqual('1,234.00') + expect(route.midPrice.invert().toFixed(0)).toEqual('0') + expect(route.midPrice.invert().toFixed(1)).toEqual('0.0') + expect(route.midPrice.invert().toFixed(2)).toEqual('0.00') + expect(route.midPrice.invert().toFixed(3)).toEqual('0.001') + expect(route.midPrice.invert().toFixed(4)).toEqual('0.0008') + expect(route.midPrice.invert().toFixed(5)).toEqual('0.00081') + expect(route.midPrice.invert().toFixed(6)).toEqual('0.000810') + expect(route.midPrice.invert().toFixed(7)).toEqual('0.0008104') + expect(route.midPrice.invert().toFixed(7, undefined, Rounding.ROUND_DOWN)).toEqual('0.0008103') + expect(route.midPrice.invert().toFixed(8)).toEqual('0.00081037') + }) + + describe('Trade', () => { + let route: Route + it('TradeType.EXACT_INPUT', () => { + route = new Route( + [ + new Pair( + new TokenAmount(tokens[1], decimalize(5, tokens[1].decimals)), + new TokenAmount(WETH, decimalize(10, WETH.decimals)) + ), + ], + tokens[1] + ) + const inputAmount = new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)) + const expectedOutputAmount = new TokenAmount(WETH, '1663192997082117548') + const trade = new Trade(route, inputAmount, TradeType.EXACT_INPUT) + expect(trade.route).toEqual(route) + expect(trade.tradeType).toEqual(TradeType.EXACT_INPUT) + expect(trade.inputAmount).toEqual(inputAmount) + expect(trade.outputAmount).toEqual(expectedOutputAmount) + + expect(trade.executionPrice.toSignificant(18)).toEqual('1.66319299708211755') + expect(trade.executionPrice.invert().toSignificant(18)).toEqual('0.601253132832080201') + expect(trade.executionPrice.quote(inputAmount)).toEqual(expectedOutputAmount) + expect(trade.executionPrice.invert().quote(expectedOutputAmount)).toEqual(inputAmount) + + expect(trade.nextMidPrice.toSignificant(18)).toEqual('1.38946783381964708') + expect(trade.nextMidPrice.invert().toSignificant(18)).toEqual('0.7197') + + expect(trade.priceImpact.toSignificant(18)).toEqual('16.8403501458941226') + }) + + it('TradeType.EXACT_OUTPUT', () => { + const outputAmount = new TokenAmount(WETH, '1663192997082117548') + const expectedInputAmount = new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)) + const trade = new Trade(route, outputAmount, TradeType.EXACT_OUTPUT) + expect(trade.route).toEqual(route) + expect(trade.tradeType).toEqual(TradeType.EXACT_OUTPUT) + expect(trade.outputAmount).toEqual(outputAmount) + expect(trade.inputAmount).toEqual(expectedInputAmount) + + expect(trade.executionPrice.toSignificant(18)).toEqual('1.66319299708211755') + expect(trade.executionPrice.invert().toSignificant(18)).toEqual('0.601253132832080201') + expect(trade.executionPrice.quote(expectedInputAmount)).toEqual(outputAmount) + expect(trade.executionPrice.invert().quote(outputAmount)).toEqual(expectedInputAmount) + + expect(trade.nextMidPrice.toSignificant(18)).toEqual('1.38946783381964708') + expect(trade.nextMidPrice.invert().toSignificant(18)).toEqual('0.7197') + + expect(trade.priceImpact.toSignificant(18)).toEqual('16.8403501458941226') + }) + + it('minimum TradeType.EXACT_INPUT', () => { + if ([9, 18].includes(tokens[1].decimals)) { + const route = new Route( + [ + new Pair( + new TokenAmount(tokens[1], decimalize(1, tokens[1].decimals)), + new TokenAmount( + WETH, + JSBI.add( + decimalize(10, WETH.decimals), + + tokens[1].decimals === 9 ? JSBI.BigInt('30090280812437312') : JSBI.BigInt('30090270812437322') + ) + ) + ), + ], + tokens[1], + WETH + ) + const outputAmount = new TokenAmount(tokens[1], '1') + const trade = new Trade(route, outputAmount, TradeType.EXACT_INPUT) + + expect(trade.priceImpact.toSignificant(18)).toEqual( + tokens[1].decimals === 9 ? '0.2500001008007499' : '0.3000000000000001' + ) + } + }) + }) + + it('TokenAmount', () => { + const amount = new TokenAmount(WETH, '1234567000000000000000') + expect(amount.toExact()).toEqual('1234.567') + expect(amount.toExact({ groupSeparator: ',' })).toEqual('1,234.567') + }) + }) + }) +}) diff --git a/packages/swap-sdk/test/fraction.test.ts b/packages/swap-sdk/test/fraction.test.ts new file mode 100644 index 000000000..aed35a797 --- /dev/null +++ b/packages/swap-sdk/test/fraction.test.ts @@ -0,0 +1,128 @@ +import { Fraction } from '../src' +import JSBI from 'jsbi' + +describe.only('Fraction', () => { + describe('#quotient', () => { + it('floor division', () => { + expect(new Fraction(JSBI.BigInt(8), JSBI.BigInt(3)).quotient).toEqual(JSBI.BigInt(2)) // one below + expect(new Fraction(JSBI.BigInt(12), JSBI.BigInt(4)).quotient).toEqual(JSBI.BigInt(3)) // exact + expect(new Fraction(JSBI.BigInt(16), JSBI.BigInt(5)).quotient).toEqual(JSBI.BigInt(3)) // one above + }) + }) + describe('#remainder', () => { + it('returns fraction after divison', () => { + expect(new Fraction(JSBI.BigInt(8), JSBI.BigInt(3)).remainder).toEqual( + new Fraction(JSBI.BigInt(2), JSBI.BigInt(3)) + ) + expect(new Fraction(JSBI.BigInt(12), JSBI.BigInt(4)).remainder).toEqual( + new Fraction(JSBI.BigInt(0), JSBI.BigInt(4)) + ) + expect(new Fraction(JSBI.BigInt(16), JSBI.BigInt(5)).remainder).toEqual( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(5)) + ) + }) + }) + describe('#invert', () => { + it('flips num and denom', () => { + expect(new Fraction(JSBI.BigInt(5), JSBI.BigInt(10)).invert().numerator).toEqual(JSBI.BigInt(10)) + expect(new Fraction(JSBI.BigInt(5), JSBI.BigInt(10)).invert().denominator).toEqual(JSBI.BigInt(5)) + }) + }) + describe('#add', () => { + it('multiples denoms and adds nums', () => { + expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).add(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toEqual( + new Fraction(JSBI.BigInt(52), JSBI.BigInt(120)) + ) + }) + + it('same denom', () => { + expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(5)).add(new Fraction(JSBI.BigInt(2), JSBI.BigInt(5)))).toEqual( + new Fraction(JSBI.BigInt(3), JSBI.BigInt(5)) + ) + }) + }) + describe('#subtract', () => { + it('multiples denoms and subtracts nums', () => { + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).subtract(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(-28), JSBI.BigInt(120))) + }) + it('same denom', () => { + expect( + new Fraction(JSBI.BigInt(3), JSBI.BigInt(5)).subtract(new Fraction(JSBI.BigInt(2), JSBI.BigInt(5))) + ).toEqual(new Fraction(JSBI.BigInt(1), JSBI.BigInt(5))) + }) + }) + describe('#lessThan', () => { + it('correct', () => { + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).lessThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toBe(true) + expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).lessThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( + false + ) + expect( + new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).lessThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toBe(false) + }) + }) + describe('#equalTo', () => { + it('correct', () => { + expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).equalTo(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( + false + ) + expect(new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).equalTo(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( + true + ) + expect(new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).equalTo(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12)))).toBe( + false + ) + }) + }) + describe('#greaterThan', () => { + it('correct', () => { + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).greaterThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toBe(false) + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).greaterThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toBe(false) + expect( + new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).greaterThan(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toBe(true) + }) + }) + describe('#multiplty', () => { + it('correct', () => { + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).multiply(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(4), JSBI.BigInt(120))) + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).multiply(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(4), JSBI.BigInt(36))) + expect( + new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).multiply(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(20), JSBI.BigInt(144))) + }) + }) + describe('#divide', () => { + it('correct', () => { + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(10)).divide(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(12), JSBI.BigInt(40))) + expect( + new Fraction(JSBI.BigInt(1), JSBI.BigInt(3)).divide(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(12), JSBI.BigInt(12))) + expect( + new Fraction(JSBI.BigInt(5), JSBI.BigInt(12)).divide(new Fraction(JSBI.BigInt(4), JSBI.BigInt(12))) + ).toEqual(new Fraction(JSBI.BigInt(60), JSBI.BigInt(48))) + }) + }) + describe('#asFraction', () => { + it('returns an equivalent but not the same reference fraction', () => { + const f = new Fraction(1, 2) + expect(f.asFraction).toEqual(f) + expect(f === f.asFraction).toEqual(false) + }) + }) +}) diff --git a/packages/swap-sdk/test/miscellaneous.test.ts b/packages/swap-sdk/test/miscellaneous.test.ts new file mode 100644 index 000000000..962eb577e --- /dev/null +++ b/packages/swap-sdk/test/miscellaneous.test.ts @@ -0,0 +1,173 @@ +import { ChainId, Token, TokenAmount, Pair, InsufficientInputAmountError } from '../src' +import { sortedInsert } from '../src/utils' + +describe('miscellaneous', () => { + it('getLiquidityMinted:0', async () => { + const tokenA = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000001', 18) + const tokenB = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000002', 18) + const pair = new Pair(new TokenAmount(tokenA, '0'), new TokenAmount(tokenB, '0')) + + expect(() => { + pair.getLiquidityMinted( + new TokenAmount(pair.liquidityToken, '0'), + new TokenAmount(tokenA, '1000'), + new TokenAmount(tokenB, '1000') + ) + }).toThrow(InsufficientInputAmountError) + + expect(() => { + pair.getLiquidityMinted( + new TokenAmount(pair.liquidityToken, '0'), + new TokenAmount(tokenA, '1000000'), + new TokenAmount(tokenB, '1') + ) + }).toThrow(InsufficientInputAmountError) + + const liquidity = pair.getLiquidityMinted( + new TokenAmount(pair.liquidityToken, '0'), + new TokenAmount(tokenA, '1001'), + new TokenAmount(tokenB, '1001') + ) + + expect(liquidity.raw.toString()).toEqual('1') + }) + + it('getLiquidityMinted:!0', async () => { + const tokenA = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000001', 18) + const tokenB = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000002', 18) + const pair = new Pair(new TokenAmount(tokenA, '10000'), new TokenAmount(tokenB, '10000')) + + expect( + pair + .getLiquidityMinted( + new TokenAmount(pair.liquidityToken, '10000'), + new TokenAmount(tokenA, '2000'), + new TokenAmount(tokenB, '2000') + ) + .raw.toString() + ).toEqual('2000') + }) + + it('getLiquidityValue:!feeOn', async () => { + const tokenA = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000001', 18) + const tokenB = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000002', 18) + const pair = new Pair(new TokenAmount(tokenA, '1000'), new TokenAmount(tokenB, '1000')) + + { + const liquidityValue = pair.getLiquidityValue( + tokenA, + new TokenAmount(pair.liquidityToken, '1000'), + new TokenAmount(pair.liquidityToken, '1000'), + false + ) + expect(liquidityValue.token.equals(tokenA)).toBe(true) + expect(liquidityValue.raw.toString()).toBe('1000') + } + + // 500 + { + const liquidityValue = pair.getLiquidityValue( + tokenA, + new TokenAmount(pair.liquidityToken, '1000'), + new TokenAmount(pair.liquidityToken, '500'), + false + ) + expect(liquidityValue.token.equals(tokenA)).toBe(true) + expect(liquidityValue.raw.toString()).toBe('500') + } + + // tokenB + { + const liquidityValue = pair.getLiquidityValue( + tokenB, + new TokenAmount(pair.liquidityToken, '1000'), + new TokenAmount(pair.liquidityToken, '1000'), + false + ) + expect(liquidityValue.token.equals(tokenB)).toBe(true) + expect(liquidityValue.raw.toString()).toBe('1000') + } + }) + + it('getLiquidityValue:feeOn', async () => { + const tokenA = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000001', 18) + const tokenB = new Token(ChainId.BSC_TESTNET, '0x0000000000000000000000000000000000000002', 18) + const pair = new Pair(new TokenAmount(tokenA, '1000'), new TokenAmount(tokenB, '1000')) + + const liquidityValue = pair.getLiquidityValue( + tokenA, + new TokenAmount(pair.liquidityToken, '500'), + new TokenAmount(pair.liquidityToken, '500'), + true, + '250000' // 500 ** 2 + ) + expect(liquidityValue.token.equals(tokenA)).toBe(true) + expect(liquidityValue.raw.toString()).toBe('917') // ceiling(1000 - (500 * (1 / 6))) + }) + + describe('#sortedInsert', () => { + const comp = (a: number, b: number) => a - b + + it('throws if maxSize is 0', () => { + expect(() => sortedInsert([], 1, 0, comp)).toThrow('MAX_SIZE_ZERO') + }) + + it('throws if items.length > maxSize', () => { + expect(() => sortedInsert([1, 2], 1, 1, comp)).toThrow('ITEMS_SIZE') + }) + + it('adds if empty', () => { + const arr: number[] = [] + expect(sortedInsert(arr, 3, 2, comp)).toEqual(null) + expect(arr).toEqual([3]) + }) + + it('adds if not full', () => { + const arr: number[] = [1, 5] + expect(sortedInsert(arr, 3, 3, comp)).toEqual(null) + expect(arr).toEqual([1, 3, 5]) + }) + + it('adds if will not be full after', () => { + const arr: number[] = [1] + expect(sortedInsert(arr, 0, 3, comp)).toEqual(null) + expect(arr).toEqual([0, 1]) + }) + + it('returns add if sorts after last', () => { + const arr = [1, 2, 3] + expect(sortedInsert(arr, 4, 3, comp)).toEqual(4) + expect(arr).toEqual([1, 2, 3]) + }) + + it('removes from end if full', () => { + const arr = [1, 3, 4] + expect(sortedInsert(arr, 2, 3, comp)).toEqual(4) + expect(arr).toEqual([1, 2, 3]) + }) + + it('uses comparator', () => { + const arr = [4, 2, 1] + expect(sortedInsert(arr, 3, 3, (a, b) => comp(a, b) * -1)).toEqual(1) + expect(arr).toEqual([4, 3, 2]) + }) + + describe('maxSize of 1', () => { + it('empty add', () => { + const arr: number[] = [] + expect(sortedInsert(arr, 3, 1, comp)).toEqual(null) + expect(arr).toEqual([3]) + }) + it('full add greater', () => { + const arr: number[] = [2] + expect(sortedInsert(arr, 3, 1, comp)).toEqual(3) + expect(arr).toEqual([2]) + }) + it('full add lesser', () => { + const arr: number[] = [4] + expect(sortedInsert(arr, 3, 1, comp)).toEqual(4) + expect(arr).toEqual([3]) + }) + }) + }) +}) diff --git a/packages/swap-sdk/test/pair.test.ts b/packages/swap-sdk/test/pair.test.ts new file mode 100644 index 000000000..4cb698a87 --- /dev/null +++ b/packages/swap-sdk/test/pair.test.ts @@ -0,0 +1,118 @@ +import { ChainId, Token, Pair, TokenAmount, WNATIVE, Price } from '../src' + +describe('Pair', () => { + const USDC = new Token(ChainId.BSC, '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', 18, 'USDC', 'USD Coin') + const DAI = new Token(ChainId.BSC, '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3', 18, 'DAI', 'DAI Stablecoin') + + describe('constructor', () => { + it('cannot be used for tokens on different chains', () => { + expect( + () => new Pair(new TokenAmount(USDC, '100'), new TokenAmount(WNATIVE[ChainId.BSC_TESTNET], '100')) + ).toThrow('CHAIN_IDS') + }) + }) + + describe('#getAddress', () => { + it('returns the correct address', () => { + expect(Pair.getAddress(USDC, DAI)).toEqual('0xadBba1EF326A33FDB754f14e62A96D5278b942Bd') + }) + }) + + describe('#token0', () => { + it('always is the token that sorts before', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '100')).token0).toEqual(DAI) + expect(new Pair(new TokenAmount(DAI, '100'), new TokenAmount(USDC, '100')).token0).toEqual(DAI) + }) + }) + describe('#token1', () => { + it('always is the token that sorts after', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '100')).token1).toEqual(USDC) + expect(new Pair(new TokenAmount(DAI, '100'), new TokenAmount(USDC, '100')).token1).toEqual(USDC) + }) + }) + describe('#reserve0', () => { + it('always comes from the token that sorts before', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '101')).reserve0).toEqual( + new TokenAmount(DAI, '101') + ) + expect(new Pair(new TokenAmount(DAI, '101'), new TokenAmount(USDC, '100')).reserve0).toEqual( + new TokenAmount(DAI, '101') + ) + }) + }) + describe('#reserve1', () => { + it('always comes from the token that sorts after', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '101')).reserve1).toEqual( + new TokenAmount(USDC, '100') + ) + expect(new Pair(new TokenAmount(DAI, '101'), new TokenAmount(USDC, '100')).reserve1).toEqual( + new TokenAmount(USDC, '100') + ) + }) + }) + + describe('#token0Price', () => { + it('returns price of token0 in terms of token1', () => { + expect(new Pair(new TokenAmount(USDC, '101'), new TokenAmount(DAI, '100')).token0Price).toEqual( + new Price(DAI, USDC, '100', '101') + ) + expect(new Pair(new TokenAmount(DAI, '100'), new TokenAmount(USDC, '101')).token0Price).toEqual( + new Price(DAI, USDC, '100', '101') + ) + }) + }) + + describe('#token1Price', () => { + it('returns price of token1 in terms of token0', () => { + expect(new Pair(new TokenAmount(USDC, '101'), new TokenAmount(DAI, '100')).token1Price).toEqual( + new Price(USDC, DAI, '101', '100') + ) + expect(new Pair(new TokenAmount(DAI, '100'), new TokenAmount(USDC, '101')).token1Price).toEqual( + new Price(USDC, DAI, '101', '100') + ) + }) + }) + + describe('#priceOf', () => { + const pair = new Pair(new TokenAmount(USDC, '101'), new TokenAmount(DAI, '100')) + it('returns price of token in terms of other token', () => { + expect(pair.priceOf(DAI)).toEqual(pair.token0Price) + expect(pair.priceOf(USDC)).toEqual(pair.token1Price) + }) + + it('throws if invalid token', () => { + expect(() => pair.priceOf(WNATIVE[ChainId.BSC])).toThrow('TOKEN') + }) + }) + + describe('#reserveOf', () => { + it('returns reserves of the given token', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '101')).reserveOf(USDC)).toEqual( + new TokenAmount(USDC, '100') + ) + expect(new Pair(new TokenAmount(DAI, '101'), new TokenAmount(USDC, '100')).reserveOf(USDC)).toEqual( + new TokenAmount(USDC, '100') + ) + }) + + it('throws if not in the pair', () => { + expect(() => + new Pair(new TokenAmount(DAI, '101'), new TokenAmount(USDC, '100')).reserveOf(WNATIVE[ChainId.BSC]) + ).toThrow('TOKEN') + }) + }) + + describe('#chainId', () => { + it('returns the token0 chainId', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '100')).chainId).toEqual(ChainId.BSC) + expect(new Pair(new TokenAmount(DAI, '100'), new TokenAmount(USDC, '100')).chainId).toEqual(ChainId.BSC) + }) + }) + describe('#involvesToken', () => { + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '100')).involvesToken(USDC)).toEqual(true) + expect(new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '100')).involvesToken(DAI)).toEqual(true) + expect( + new Pair(new TokenAmount(USDC, '100'), new TokenAmount(DAI, '100')).involvesToken(WNATIVE[ChainId.BSC]) + ).toEqual(false) + }) +}) diff --git a/packages/swap-sdk/test/route.test.ts b/packages/swap-sdk/test/route.test.ts new file mode 100644 index 000000000..780e11ede --- /dev/null +++ b/packages/swap-sdk/test/route.test.ts @@ -0,0 +1,40 @@ +import { Token, WNATIVE, ChainId, Pair, TokenAmount, Route, ETHER } from '../src' + +describe('Route', () => { + const token0 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000001', 18, 't0') + const token1 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000002', 18, 't1') + const weth = WNATIVE[ChainId.BSC] + const pair_0_1 = new Pair(new TokenAmount(token0, '100'), new TokenAmount(token1, '200')) + const pair_0_weth = new Pair(new TokenAmount(token0, '100'), new TokenAmount(weth, '100')) + const pair_1_weth = new Pair(new TokenAmount(token1, '175'), new TokenAmount(weth, '100')) + + it('constructs a path from the tokens', () => { + const route = new Route([pair_0_1], token0) + expect(route.pairs).toEqual([pair_0_1]) + expect(route.path).toEqual([token0, token1]) + expect(route.input).toEqual(token0) + expect(route.output).toEqual(token1) + expect(route.chainId).toEqual(ChainId.BSC) + }) + + it('can have a token as both input and output', () => { + const route = new Route([pair_0_weth, pair_0_1, pair_1_weth], weth) + expect(route.pairs).toEqual([pair_0_weth, pair_0_1, pair_1_weth]) + expect(route.input).toEqual(weth) + expect(route.output).toEqual(weth) + }) + + it('supports ether input', () => { + const route = new Route([pair_0_weth], ETHER) + expect(route.pairs).toEqual([pair_0_weth]) + expect(route.input).toEqual(ETHER) + expect(route.output).toEqual(token0) + }) + + it('supports ether output', () => { + const route = new Route([pair_0_weth], token0, ETHER) + expect(route.pairs).toEqual([pair_0_weth]) + expect(route.input).toEqual(token0) + expect(route.output).toEqual(ETHER) + }) +}) diff --git a/packages/swap-sdk/test/router.test.ts b/packages/swap-sdk/test/router.test.ts new file mode 100644 index 000000000..251725f91 --- /dev/null +++ b/packages/swap-sdk/test/router.test.ts @@ -0,0 +1,253 @@ +import invariant from 'tiny-invariant' +import { + ChainId, + CurrencyAmount, + ETHER, + Pair, + Percent, + Route, + Router, + Token, + TokenAmount, + Trade, + WNATIVE, +} from '../src' +import JSBI from 'jsbi' + +function checkDeadline(deadline: string[] | string): void { + expect(typeof deadline).toBe('string') + invariant(typeof deadline === 'string') + // less than 5 seconds on the deadline + expect(new Date().getTime() / 1000 - parseInt(deadline)).toBeLessThanOrEqual(5) +} + +describe('Router', () => { + const token0 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000001', 18, 't0') + const token1 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000002', 18, 't1') + + const pair_0_1 = new Pair(new TokenAmount(token0, JSBI.BigInt(1000)), new TokenAmount(token1, JSBI.BigInt(1000))) + + const pair_weth_0 = new Pair(new TokenAmount(WNATIVE[ChainId.BSC], '1000'), new TokenAmount(token0, '1000')) + + describe('#swapCallParameters', () => { + describe('exact in', () => { + it('ether to token1', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_weth_0, pair_0_1], ETHER, token1), CurrencyAmount.ether(JSBI.BigInt(100))), + { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } + ) + expect(result.methodName).toEqual('swapExactETHForTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x51', + [WNATIVE[ChainId.BSC].address, token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x64') + checkDeadline(result.args[result.args.length - 1]) + }) + + it('deadline specified', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_weth_0, pair_0_1], ETHER, token1), CurrencyAmount.ether(JSBI.BigInt(100))), + { + deadline: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + } + ) + expect(result.methodName).toEqual('swapExactETHForTokens') + expect(result.args).toEqual([ + '0x51', + [WNATIVE[ChainId.BSC].address, token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + '0x32', + ]) + expect(result.value).toEqual('0x64') + }) + + it('token1 to ether', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_0_1, pair_weth_0], token1, ETHER), new TokenAmount(token1, JSBI.BigInt(100))), + { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } + ) + expect(result.methodName).toEqual('swapExactTokensForETH') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + '0x51', + [token1.address, token0.address, WNATIVE[ChainId.BSC].address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x0') + checkDeadline(result.args[result.args.length - 1]) + }) + it('token0 to token1', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_0_1], token0, token1), new TokenAmount(token0, JSBI.BigInt(100))), + { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } + ) + expect(result.methodName).toEqual('swapExactTokensForTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + '0x59', + [token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x0') + checkDeadline(result.args[result.args.length - 1]) + }) + }) + describe('exact out', () => { + it('ether to token1', () => { + const result = Router.swapCallParameters( + Trade.exactOut(new Route([pair_weth_0, pair_0_1], ETHER, token1), new TokenAmount(token1, JSBI.BigInt(100))), + { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } + ) + expect(result.methodName).toEqual('swapETHForExactTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + [WNATIVE[ChainId.BSC].address, token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x80') + checkDeadline(result.args[result.args.length - 1]) + }) + it('token1 to ether', () => { + const result = Router.swapCallParameters( + Trade.exactOut(new Route([pair_0_1, pair_weth_0], token1, ETHER), CurrencyAmount.ether(JSBI.BigInt(100))), + { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } + ) + expect(result.methodName).toEqual('swapTokensForExactETH') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + '0x80', + [token1.address, token0.address, WNATIVE[ChainId.BSC].address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x0') + checkDeadline(result.args[result.args.length - 1]) + }) + it('token0 to token1', () => { + const result = Router.swapCallParameters( + Trade.exactOut(new Route([pair_0_1], token0, token1), new TokenAmount(token1, JSBI.BigInt(100))), + { ttl: 50, recipient: '0x0000000000000000000000000000000000000004', allowedSlippage: new Percent('1', '100') } + ) + expect(result.methodName).toEqual('swapTokensForExactTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + '0x71', + [token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x0') + checkDeadline(result.args[result.args.length - 1]) + }) + }) + describe('supporting fee on transfer', () => { + describe('exact in', () => { + it('ether to token1', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_weth_0, pair_0_1], ETHER, token1), CurrencyAmount.ether(JSBI.BigInt(100))), + { + ttl: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + feeOnTransfer: true, + } + ) + expect(result.methodName).toEqual('swapExactETHForTokensSupportingFeeOnTransferTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x51', + [WNATIVE[ChainId.BSC].address, token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x64') + checkDeadline(result.args[result.args.length - 1]) + }) + it('token1 to ether', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_0_1, pair_weth_0], token1, ETHER), new TokenAmount(token1, JSBI.BigInt(100))), + { + ttl: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + feeOnTransfer: true, + } + ) + expect(result.methodName).toEqual('swapExactTokensForETHSupportingFeeOnTransferTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + '0x51', + [token1.address, token0.address, WNATIVE[ChainId.BSC].address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x0') + checkDeadline(result.args[result.args.length - 1]) + }) + it('token0 to token1', () => { + const result = Router.swapCallParameters( + Trade.exactIn(new Route([pair_0_1], token0, token1), new TokenAmount(token0, JSBI.BigInt(100))), + { + ttl: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + feeOnTransfer: true, + } + ) + expect(result.methodName).toEqual('swapExactTokensForTokensSupportingFeeOnTransferTokens') + expect(result.args.slice(0, -1)).toEqual([ + '0x64', + '0x59', + [token0.address, token1.address], + '0x0000000000000000000000000000000000000004', + ]) + expect(result.value).toEqual('0x0') + checkDeadline(result.args[result.args.length - 1]) + }) + }) + describe('exact out', () => { + it('ether to token1', () => { + expect(() => + Router.swapCallParameters( + Trade.exactOut( + new Route([pair_weth_0, pair_0_1], ETHER, token1), + new TokenAmount(token1, JSBI.BigInt(100)) + ), + { + ttl: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + feeOnTransfer: true, + } + ) + ).toThrow('EXACT_OUT_FOT') + }) + it('token1 to ether', () => { + expect(() => + Router.swapCallParameters( + Trade.exactOut(new Route([pair_0_1, pair_weth_0], token1, ETHER), CurrencyAmount.ether(JSBI.BigInt(100))), + { + ttl: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + feeOnTransfer: true, + } + ) + ).toThrow('EXACT_OUT_FOT') + }) + it('token0 to token1', () => { + expect(() => + Router.swapCallParameters( + Trade.exactOut(new Route([pair_0_1], token0, token1), new TokenAmount(token1, JSBI.BigInt(100))), + { + ttl: 50, + recipient: '0x0000000000000000000000000000000000000004', + allowedSlippage: new Percent('1', '100'), + feeOnTransfer: true, + } + ) + ).toThrow('EXACT_OUT_FOT') + }) + }) + }) + }) +}) diff --git a/packages/swap-sdk/test/token.test.ts b/packages/swap-sdk/test/token.test.ts new file mode 100644 index 000000000..b4bb7cbba --- /dev/null +++ b/packages/swap-sdk/test/token.test.ts @@ -0,0 +1,37 @@ +import { ChainId, Token } from '../src' + +describe('Token', () => { + const ADDRESS_ONE = '0x0000000000000000000000000000000000000001' + const ADDRESS_TWO = '0x0000000000000000000000000000000000000002' + + describe('#equals', () => { + it('fails if address differs', () => { + expect(new Token(ChainId.BSC, ADDRESS_ONE, 18).equals(new Token(ChainId.BSC, ADDRESS_TWO, 18))).toBe(false) + }) + + it('false if chain id differs', () => { + expect(new Token(ChainId.BSC_TESTNET, ADDRESS_ONE, 18).equals(new Token(ChainId.BSC, ADDRESS_ONE, 18))).toBe( + false + ) + }) + + it('true if only decimals differs', () => { + expect(new Token(ChainId.BSC, ADDRESS_ONE, 9).equals(new Token(ChainId.BSC, ADDRESS_ONE, 18))).toBe(true) + }) + + it('true if address is the same', () => { + expect(new Token(ChainId.BSC, ADDRESS_ONE, 18).equals(new Token(ChainId.BSC, ADDRESS_ONE, 18))).toBe(true) + }) + + it('true on reference equality', () => { + const token = new Token(ChainId.BSC, ADDRESS_ONE, 18) + expect(token.equals(token)).toBe(true) + }) + + it('true even if name/symbol/decimals/projectLink differ', () => { + const tokenA = new Token(ChainId.BSC, ADDRESS_ONE, 9, 'abc', 'def', 'https://www.binance.org/') + const tokenB = new Token(ChainId.BSC, ADDRESS_ONE, 18, 'ghi', 'jkl', 'https://coinmarketcap.com/') + expect(tokenA.equals(tokenB)).toBe(true) + }) + }) +}) diff --git a/packages/swap-sdk/test/trade.test.ts b/packages/swap-sdk/test/trade.test.ts new file mode 100644 index 000000000..5a9b5493e --- /dev/null +++ b/packages/swap-sdk/test/trade.test.ts @@ -0,0 +1,404 @@ +import JSBI from 'jsbi' +import { + ChainId, + ETHER, + CurrencyAmount, + Pair, + Percent, + Route, + Token, + TokenAmount, + Trade, + TradeType, + WNATIVE, +} from '../src' + +describe('Trade', () => { + const token0 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000001', 18, 't0') + const token1 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000002', 18, 't1') + const token2 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000003', 18, 't2') + const token3 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000004', 18, 't3') + + const pair_0_1 = new Pair(new TokenAmount(token0, JSBI.BigInt(1000)), new TokenAmount(token1, JSBI.BigInt(1000))) + const pair_0_2 = new Pair(new TokenAmount(token0, JSBI.BigInt(1000)), new TokenAmount(token2, JSBI.BigInt(1100))) + const pair_0_3 = new Pair(new TokenAmount(token0, JSBI.BigInt(1000)), new TokenAmount(token3, JSBI.BigInt(900))) + const pair_1_2 = new Pair(new TokenAmount(token1, JSBI.BigInt(1200)), new TokenAmount(token2, JSBI.BigInt(1000))) + const pair_1_3 = new Pair(new TokenAmount(token1, JSBI.BigInt(1200)), new TokenAmount(token3, JSBI.BigInt(1300))) + + const pair_weth_0 = new Pair( + new TokenAmount(WNATIVE[ChainId.BSC], JSBI.BigInt(1000)), + new TokenAmount(token0, JSBI.BigInt(1000)) + ) + + const empty_pair_0_1 = new Pair(new TokenAmount(token0, JSBI.BigInt(0)), new TokenAmount(token1, JSBI.BigInt(0))) + + it('can be constructed with ETHER as input', () => { + const trade = new Trade( + new Route([pair_weth_0], ETHER), + CurrencyAmount.ether(JSBI.BigInt(100)), + TradeType.EXACT_INPUT + ) + expect(trade.inputAmount.currency).toEqual(ETHER) + expect(trade.outputAmount.currency).toEqual(token0) + }) + it('can be constructed with ETHER as input for exact output', () => { + const trade = new Trade( + new Route([pair_weth_0], ETHER, token0), + new TokenAmount(token0, JSBI.BigInt(100)), + TradeType.EXACT_OUTPUT + ) + expect(trade.inputAmount.currency).toEqual(ETHER) + expect(trade.outputAmount.currency).toEqual(token0) + }) + + it('can be constructed with ETHER as output', () => { + const trade = new Trade( + new Route([pair_weth_0], token0, ETHER), + CurrencyAmount.ether(JSBI.BigInt(100)), + TradeType.EXACT_OUTPUT + ) + expect(trade.inputAmount.currency).toEqual(token0) + expect(trade.outputAmount.currency).toEqual(ETHER) + }) + it('can be constructed with ETHER as output for exact input', () => { + const trade = new Trade( + new Route([pair_weth_0], token0, ETHER), + new TokenAmount(token0, JSBI.BigInt(100)), + TradeType.EXACT_INPUT + ) + expect(trade.inputAmount.currency).toEqual(token0) + expect(trade.outputAmount.currency).toEqual(ETHER) + }) + + describe('#bestTradeExactIn', () => { + it('throws with empty pairs', () => { + expect(() => Trade.bestTradeExactIn([], new TokenAmount(token0, JSBI.BigInt(100)), token2)).toThrow('PAIRS') + }) + it('throws with max hops of 0', () => { + expect(() => + Trade.bestTradeExactIn([pair_0_2], new TokenAmount(token0, JSBI.BigInt(100)), token2, { maxHops: 0 }) + ).toThrow('MAX_HOPS') + }) + + it('provides best route', () => { + const result = Trade.bestTradeExactIn( + [pair_0_1, pair_0_2, pair_1_2], + new TokenAmount(token0, JSBI.BigInt(100)), + token2 + ) + expect(result).toHaveLength(2) + expect(result[0].route.pairs).toHaveLength(1) // 0 -> 2 at 10:11 + expect(result[0].route.path).toEqual([token0, token2]) + expect(result[0].inputAmount).toEqual(new TokenAmount(token0, JSBI.BigInt(100))) + expect(result[0].outputAmount).toEqual(new TokenAmount(token2, JSBI.BigInt(99))) + expect(result[1].route.pairs).toHaveLength(2) // 0 -> 1 -> 2 at 12:12:10 + expect(result[1].route.path).toEqual([token0, token1, token2]) + expect(result[1].inputAmount).toEqual(new TokenAmount(token0, JSBI.BigInt(100))) + expect(result[1].outputAmount).toEqual(new TokenAmount(token2, JSBI.BigInt(69))) + }) + + it('doesnt throw for zero liquidity pairs', () => { + expect(Trade.bestTradeExactIn([empty_pair_0_1], new TokenAmount(token0, JSBI.BigInt(100)), token1)).toHaveLength( + 0 + ) + }) + + it('respects maxHops', () => { + const result = Trade.bestTradeExactIn( + [pair_0_1, pair_0_2, pair_1_2], + new TokenAmount(token0, JSBI.BigInt(10)), + token2, + { maxHops: 1 } + ) + expect(result).toHaveLength(1) + expect(result[0].route.pairs).toHaveLength(1) // 0 -> 2 at 10:11 + expect(result[0].route.path).toEqual([token0, token2]) + }) + + it('insufficient input for one pair', () => { + const result = Trade.bestTradeExactIn( + [pair_0_1, pair_0_2, pair_1_2], + new TokenAmount(token0, JSBI.BigInt(1)), + token2 + ) + expect(result).toHaveLength(1) + expect(result[0].route.pairs).toHaveLength(1) // 0 -> 2 at 10:11 + expect(result[0].route.path).toEqual([token0, token2]) + expect(result[0].outputAmount).toEqual(new TokenAmount(token2, JSBI.BigInt(1))) + }) + + it('respects n', () => { + const result = Trade.bestTradeExactIn( + [pair_0_1, pair_0_2, pair_1_2], + new TokenAmount(token0, JSBI.BigInt(10)), + token2, + { maxNumResults: 1 } + ) + + expect(result).toHaveLength(1) + }) + + it('no path', () => { + const result = Trade.bestTradeExactIn( + [pair_0_1, pair_0_3, pair_1_3], + new TokenAmount(token0, JSBI.BigInt(10)), + token2 + ) + expect(result).toHaveLength(0) + }) + + it('works for ETHER currency input', () => { + const result = Trade.bestTradeExactIn( + [pair_weth_0, pair_0_1, pair_0_3, pair_1_3], + CurrencyAmount.ether(JSBI.BigInt(100)), + token3 + ) + expect(result).toHaveLength(2) + expect(result[0].inputAmount.currency).toEqual(ETHER) + expect(result[0].route.path).toEqual([WNATIVE[ChainId.BSC], token0, token1, token3]) + expect(result[0].outputAmount.currency).toEqual(token3) + expect(result[1].inputAmount.currency).toEqual(ETHER) + expect(result[1].route.path).toEqual([WNATIVE[ChainId.BSC], token0, token3]) + expect(result[1].outputAmount.currency).toEqual(token3) + }) + it('works for ETHER currency output', () => { + const result = Trade.bestTradeExactIn( + [pair_weth_0, pair_0_1, pair_0_3, pair_1_3], + new TokenAmount(token3, JSBI.BigInt(100)), + ETHER + ) + expect(result).toHaveLength(2) + expect(result[0].inputAmount.currency).toEqual(token3) + expect(result[0].route.path).toEqual([token3, token0, WNATIVE[ChainId.BSC]]) + expect(result[0].outputAmount.currency).toEqual(ETHER) + expect(result[1].inputAmount.currency).toEqual(token3) + expect(result[1].route.path).toEqual([token3, token1, token0, WNATIVE[ChainId.BSC]]) + expect(result[1].outputAmount.currency).toEqual(ETHER) + }) + }) + + describe('#maximumAmountIn', () => { + describe('tradeType = EXACT_INPUT', () => { + const exactIn = new Trade( + new Route([pair_0_1, pair_1_2], token0), + new TokenAmount(token0, JSBI.BigInt(100)), + TradeType.EXACT_INPUT + ) + it('throws if less than 0', () => { + expect(() => exactIn.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( + 'SLIPPAGE_TOLERANCE' + ) + }) + it('returns exact if 0', () => { + expect(exactIn.maximumAmountIn(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual(exactIn.inputAmount) + }) + it('returns exact if nonzero', () => { + expect(exactIn.maximumAmountIn(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token0, JSBI.BigInt(100)) + ) + expect(exactIn.maximumAmountIn(new Percent(JSBI.BigInt(5), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token0, JSBI.BigInt(100)) + ) + expect(exactIn.maximumAmountIn(new Percent(JSBI.BigInt(200), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token0, JSBI.BigInt(100)) + ) + }) + }) + describe('tradeType = EXACT_OUTPUT', () => { + const exactOut = new Trade( + new Route([pair_0_1, pair_1_2], token0), + new TokenAmount(token2, JSBI.BigInt(100)), + TradeType.EXACT_OUTPUT + ) + + it('throws if less than 0', () => { + expect(() => exactOut.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( + 'SLIPPAGE_TOLERANCE' + ) + }) + it('returns exact if 0', () => { + expect(exactOut.maximumAmountIn(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual(exactOut.inputAmount) + }) + it('returns slippage amount if nonzero', () => { + expect(exactOut.maximumAmountIn(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token0, JSBI.BigInt(156)) + ) + expect(exactOut.maximumAmountIn(new Percent(JSBI.BigInt(5), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token0, JSBI.BigInt(163)) + ) + expect(exactOut.maximumAmountIn(new Percent(JSBI.BigInt(200), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token0, JSBI.BigInt(468)) + ) + }) + }) + }) + + describe('#minimumAmountOut', () => { + describe('tradeType = EXACT_INPUT', () => { + const exactIn = new Trade( + new Route([pair_0_1, pair_1_2], token0), + new TokenAmount(token0, JSBI.BigInt(100)), + TradeType.EXACT_INPUT + ) + it('throws if less than 0', () => { + expect(() => exactIn.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( + 'SLIPPAGE_TOLERANCE' + ) + }) + it('returns exact if 0', () => { + expect(exactIn.minimumAmountOut(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual(exactIn.outputAmount) + }) + it('returns exact if nonzero', () => { + expect(exactIn.minimumAmountOut(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token2, JSBI.BigInt(69)) + ) + expect(exactIn.minimumAmountOut(new Percent(JSBI.BigInt(5), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token2, JSBI.BigInt(65)) + ) + expect(exactIn.minimumAmountOut(new Percent(JSBI.BigInt(200), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token2, JSBI.BigInt(23)) + ) + }) + }) + describe('tradeType = EXACT_OUTPUT', () => { + const exactOut = new Trade( + new Route([pair_0_1, pair_1_2], token0), + new TokenAmount(token2, JSBI.BigInt(100)), + TradeType.EXACT_OUTPUT + ) + + it('throws if less than 0', () => { + expect(() => exactOut.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( + 'SLIPPAGE_TOLERANCE' + ) + }) + it('returns exact if 0', () => { + expect(exactOut.minimumAmountOut(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual(exactOut.outputAmount) + }) + it('returns slippage amount if nonzero', () => { + expect(exactOut.minimumAmountOut(new Percent(JSBI.BigInt(0), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token2, JSBI.BigInt(100)) + ) + expect(exactOut.minimumAmountOut(new Percent(JSBI.BigInt(5), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token2, JSBI.BigInt(100)) + ) + expect(exactOut.minimumAmountOut(new Percent(JSBI.BigInt(200), JSBI.BigInt(100)))).toEqual( + new TokenAmount(token2, JSBI.BigInt(100)) + ) + }) + }) + }) + + describe('#bestTradeExactOut', () => { + it('throws with empty pairs', () => { + expect(() => Trade.bestTradeExactOut([], token0, new TokenAmount(token2, JSBI.BigInt(100)))).toThrow('PAIRS') + }) + it('throws with max hops of 0', () => { + expect(() => + Trade.bestTradeExactOut([pair_0_2], token0, new TokenAmount(token2, JSBI.BigInt(100)), { maxHops: 0 }) + ).toThrow('MAX_HOPS') + }) + + it('provides best route', () => { + const result = Trade.bestTradeExactOut( + [pair_0_1, pair_0_2, pair_1_2], + token0, + new TokenAmount(token2, JSBI.BigInt(100)) + ) + expect(result).toHaveLength(2) + expect(result[0].route.pairs).toHaveLength(1) // 0 -> 2 at 10:11 + expect(result[0].route.path).toEqual([token0, token2]) + expect(result[0].inputAmount).toEqual(new TokenAmount(token0, JSBI.BigInt(101))) + expect(result[0].outputAmount).toEqual(new TokenAmount(token2, JSBI.BigInt(100))) + expect(result[1].route.pairs).toHaveLength(2) // 0 -> 1 -> 2 at 12:12:10 + expect(result[1].route.path).toEqual([token0, token1, token2]) + expect(result[1].inputAmount).toEqual(new TokenAmount(token0, JSBI.BigInt(156))) + expect(result[1].outputAmount).toEqual(new TokenAmount(token2, JSBI.BigInt(100))) + }) + + it('doesnt throw for zero liquidity pairs', () => { + expect(Trade.bestTradeExactOut([empty_pair_0_1], token1, new TokenAmount(token1, JSBI.BigInt(100)))).toHaveLength( + 0 + ) + }) + + it('respects maxHops', () => { + const result = Trade.bestTradeExactOut( + [pair_0_1, pair_0_2, pair_1_2], + token0, + new TokenAmount(token2, JSBI.BigInt(10)), + { maxHops: 1 } + ) + expect(result).toHaveLength(1) + expect(result[0].route.pairs).toHaveLength(1) // 0 -> 2 at 10:11 + expect(result[0].route.path).toEqual([token0, token2]) + }) + + it('insufficient liquidity', () => { + const result = Trade.bestTradeExactOut( + [pair_0_1, pair_0_2, pair_1_2], + token0, + new TokenAmount(token2, JSBI.BigInt(1200)) + ) + expect(result).toHaveLength(0) + }) + + it('insufficient liquidity in one pair but not the other', () => { + const result = Trade.bestTradeExactOut( + [pair_0_1, pair_0_2, pair_1_2], + token0, + new TokenAmount(token2, JSBI.BigInt(1050)) + ) + expect(result).toHaveLength(1) + }) + + it('respects n', () => { + const result = Trade.bestTradeExactOut( + [pair_0_1, pair_0_2, pair_1_2], + token0, + new TokenAmount(token2, JSBI.BigInt(10)), + { maxNumResults: 1 } + ) + + expect(result).toHaveLength(1) + }) + + it('no path', () => { + const result = Trade.bestTradeExactOut( + [pair_0_1, pair_0_3, pair_1_3], + token0, + new TokenAmount(token2, JSBI.BigInt(10)) + ) + expect(result).toHaveLength(0) + }) + + it('works for ETHER currency input', () => { + const result = Trade.bestTradeExactOut( + [pair_weth_0, pair_0_1, pair_0_3, pair_1_3], + ETHER, + new TokenAmount(token3, JSBI.BigInt(100)) + ) + expect(result).toHaveLength(2) + expect(result[0].inputAmount.currency).toEqual(ETHER) + expect(result[0].route.path).toEqual([WNATIVE[ChainId.BSC], token0, token1, token3]) + expect(result[0].outputAmount.currency).toEqual(token3) + expect(result[1].inputAmount.currency).toEqual(ETHER) + expect(result[1].route.path).toEqual([WNATIVE[ChainId.BSC], token0, token3]) + expect(result[1].outputAmount.currency).toEqual(token3) + }) + it('works for ETHER currency output', () => { + const result = Trade.bestTradeExactOut( + [pair_weth_0, pair_0_1, pair_0_3, pair_1_3], + token3, + CurrencyAmount.ether(JSBI.BigInt(100)) + ) + expect(result).toHaveLength(2) + expect(result[0].inputAmount.currency).toEqual(token3) + expect(result[0].route.path).toEqual([token3, token0, WNATIVE[ChainId.BSC]]) + expect(result[0].outputAmount.currency).toEqual(ETHER) + expect(result[1].inputAmount.currency).toEqual(token3) + expect(result[1].route.path).toEqual([token3, token1, token0, WNATIVE[ChainId.BSC]]) + expect(result[1].outputAmount.currency).toEqual(ETHER) + }) + }) +}) diff --git a/packages/swap-sdk/tsconfig.json b/packages/swap-sdk/tsconfig.json new file mode 100644 index 000000000..1a6d420f9 --- /dev/null +++ b/packages/swap-sdk/tsconfig.json @@ -0,0 +1,29 @@ +{ + "include": ["src", "test"], + "compilerOptions": { + "target": "es2018", + "module": "esnext", + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./", + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "baseUrl": "./", + "paths": { + "*": ["src/*", "node_modules/*"] + }, + "esModuleInterop": true, + "resolveJsonModule": true + } +} diff --git a/scripts/updateLPsAPR.ts b/scripts/updateLPsAPR.ts index 075aaaa8b..d3af323b3 100644 --- a/scripts/updateLPsAPR.ts +++ b/scripts/updateLPsAPR.ts @@ -97,7 +97,7 @@ const getAprsForFarmGroup = async (addresses: string[], blockWeekAgo: number): P } const fetchAndUpdateLPsAPR = async () => { - const lowerCaseAddresses = farmsConfig.map((farm) => farm.lpAddresses[ChainId.MAINNET].toLowerCase()) + const lowerCaseAddresses = farmsConfig.map((farm) => farm.lpAddresses[ChainId.BSC].toLowerCase()) console.info(`Fetching farm data for ${lowerCaseAddresses.length} addresses`) // Split it into chunks of 30 addresses to avoid gateway timeout const addressesInGroups = chunk(lowerCaseAddresses, 30) diff --git a/src/__tests__/utils/addressHelpers.test.ts b/src/__tests__/utils/addressHelpers.test.ts index 354446ba6..b77d937fa 100644 --- a/src/__tests__/utils/addressHelpers.test.ts +++ b/src/__tests__/utils/addressHelpers.test.ts @@ -7,18 +7,15 @@ describe('getAddress', () => { } it(`get address for mainnet (chainId 56)`, () => { - process.env.NEXT_PUBLIC_CHAIN_ID = '56' const expected = address[56] - expect(getAddress(address)).toEqual(expected) + expect(getAddress(address, 56)).toEqual(expected) }) it(`get address for testnet (chainId 97)`, () => { - process.env.NEXT_PUBLIC_CHAIN_ID = '97' const expected = address[97] - expect(getAddress(address)).toEqual(expected) + expect(getAddress(address, 97)).toEqual(expected) }) it(`get address for any other network (chainId 31337)`, () => { - process.env.NEXT_PUBLIC_CHAIN_ID = '31337' const expected = address[56] - expect(getAddress(address)).toEqual(expected) + expect(getAddress(address, 31337)).toEqual(expected) }) }) diff --git a/src/__tests__/utils/getLpAddress.test.ts b/src/__tests__/utils/getLpAddress.test.ts index f7454ce1b..e249edc1e 100644 --- a/src/__tests__/utils/getLpAddress.test.ts +++ b/src/__tests__/utils/getLpAddress.test.ts @@ -3,8 +3,8 @@ import getLpAddress from 'utils/getLpAddress' const CAKE_AS_STRING = '0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82' const BUSD_AS_STRING = '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56' -const CAKE_AS_TOKEN = new Token(ChainId.MAINNET, CAKE_AS_STRING, 18) -const BUSD_AS_TOKEN = new Token(ChainId.MAINNET, BUSD_AS_STRING, 18) +const CAKE_AS_TOKEN = new Token(ChainId.BSC, CAKE_AS_STRING, 18) +const BUSD_AS_TOKEN = new Token(ChainId.BSC, BUSD_AS_STRING, 18) const CAKE_BUSD_LP = '0x804678fa97d91B974ec2af3c843270886528a9E6' describe('getLpAddress', () => { diff --git a/src/__tests__/utils/index.test.ts b/src/__tests__/utils/index.test.ts index 29b7e577d..5dd143e7b 100644 --- a/src/__tests__/utils/index.test.ts +++ b/src/__tests__/utils/index.test.ts @@ -7,22 +7,22 @@ import { calculateSlippageAmount, basisPointsToPercent } from 'utils/exchange' describe('utils', () => { describe('#getBscScanLink', () => { it('correct for tx', () => { - expect(getBscScanLink('abc', 'transaction', ChainId.MAINNET)).toEqual('https://bscscan.com/tx/abc') + expect(getBscScanLink('abc', 'transaction', ChainId.BSC)).toEqual('https://bscscan.com/tx/abc') }) it('correct for token', () => { - expect(getBscScanLink('abc', 'token', ChainId.MAINNET)).toEqual('https://bscscan.com/token/abc') + expect(getBscScanLink('abc', 'token', ChainId.BSC)).toEqual('https://bscscan.com/token/abc') }) it('correct for address', () => { - expect(getBscScanLink('abc', 'address', ChainId.MAINNET)).toEqual('https://bscscan.com/address/abc') + expect(getBscScanLink('abc', 'address', ChainId.BSC)).toEqual('https://bscscan.com/address/abc') }) it('enum', () => { - expect(getBscScanLink('abc', 'address', ChainId.TESTNET)).toEqual('https://testnet.bscscan.com/address/abc') + expect(getBscScanLink('abc', 'address', ChainId.BSC_TESTNET)).toEqual('https://testnet.bscscan.com/address/abc') }) }) describe('#calculateSlippageAmount', () => { it('bounds are correct', () => { - const tokenAmount = new TokenAmount(new Token(ChainId.MAINNET, AddressZero, 0), '100') + const tokenAmount = new TokenAmount(new Token(ChainId.BSC, AddressZero, 0), '100') expect(() => calculateSlippageAmount(tokenAmount, -1)).toThrow() expect(calculateSlippageAmount(tokenAmount, 0).map((bound) => bound.toString())).toEqual(['100', '100']) expect(calculateSlippageAmount(tokenAmount, 100).map((bound) => bound.toString())).toEqual(['99', '101']) diff --git a/src/__tests__/utils/prices.test.ts b/src/__tests__/utils/prices.test.ts index 210412330..744f65ea9 100644 --- a/src/__tests__/utils/prices.test.ts +++ b/src/__tests__/utils/prices.test.ts @@ -2,9 +2,9 @@ import { ChainId, JSBI, Pair, Route, Token, TokenAmount, Trade, TradeType } from import { computeTradePriceBreakdown } from 'utils/exchange' describe('prices', () => { - const token1 = new Token(ChainId.MAINNET, '0x0000000000000000000000000000000000000001', 18) - const token2 = new Token(ChainId.MAINNET, '0x0000000000000000000000000000000000000002', 18) - const token3 = new Token(ChainId.MAINNET, '0x0000000000000000000000000000000000000003', 18) + const token1 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000001', 18) + const token2 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000002', 18) + const token3 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000003', 18) const pair12 = new Pair(new TokenAmount(token1, JSBI.BigInt(10000)), new TokenAmount(token2, JSBI.BigInt(20000))) const pair23 = new Pair(new TokenAmount(token2, JSBI.BigInt(20000)), new TokenAmount(token3, JSBI.BigInt(30000))) diff --git a/src/__tests__/utils/utils.test.ts b/src/__tests__/utils/utils.test.ts index 65b082009..9b200d98b 100644 --- a/src/__tests__/utils/utils.test.ts +++ b/src/__tests__/utils/utils.test.ts @@ -9,10 +9,10 @@ describe('getActiveMenuItem', () => { const pathname = '/swap' // When - const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT) }) + const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT, false, undefined) }) // Then - expect(result).toEqual(menuConfig(mockT)[0]) + expect(result).toEqual(menuConfig(mockT, false, undefined)[0]) }) it('should return an active item if pathname found in subitems', () => { @@ -20,10 +20,10 @@ describe('getActiveMenuItem', () => { const pathname = '/pools' // When - const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT) }) + const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT, false, undefined) }) // Then - expect(result).toEqual(menuConfig(mockT)[1]) + expect(result).toEqual(menuConfig(mockT, false, undefined)[1]) }) it('should not return an item that only includes pathname but not starts with', () => { @@ -31,10 +31,10 @@ describe('getActiveMenuItem', () => { const pathname = '/info/pools' // When - const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT) }) + const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT, false, undefined) }) // Then - expect(result).toEqual(menuConfig(mockT)[4]) + expect(result).toEqual(menuConfig(mockT, false, undefined)[4]) }) it('should return undefined if item is not found', () => { @@ -42,7 +42,7 @@ describe('getActiveMenuItem', () => { const pathname = '/corgi' // When - const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT) }) + const result = getActiveMenuItem({ pathname, menuConfig: menuConfig(mockT, false, undefined) }) // Then expect(result).toEqual(undefined) @@ -55,7 +55,7 @@ describe('getActiveSubMenuItem', () => { const pathname = '/' // When - const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT)[1] }) + const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT, false, undefined)[1] }) // Then expect(result).toEqual(undefined) @@ -66,10 +66,10 @@ describe('getActiveSubMenuItem', () => { const pathname = '/pools' // When - const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT)[1] }) + const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT, false, undefined)[1] }) // Then - expect(result).toEqual(menuConfig(mockT)[1].items[1]) + expect(result).toEqual(menuConfig(mockT, false, undefined)[1].items[1]) }) it('should return the item with the longest href when multiple items are found', () => { @@ -77,10 +77,10 @@ describe('getActiveSubMenuItem', () => { const pathname = '/nfts/collections/0xDf7952B35f24aCF7fC0487D01c8d5690a60DBa07' // When - const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT)[3] }) + const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT, false, undefined)[3] }) // Then - expect(result).toEqual(menuConfig(mockT)[3].items[1]) + expect(result).toEqual(menuConfig(mockT, false, undefined)[3].items[1]) }) it('should return undefined if item is not found', () => { @@ -88,7 +88,7 @@ describe('getActiveSubMenuItem', () => { const pathname = '/corgi' // When - const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT)[1] }) + const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT, false, undefined)[1] }) // Then expect(result).toEqual(undefined) @@ -99,9 +99,11 @@ describe('getActiveSubMenuItem', () => { const pathname = '/nfts/collections/0xDf7952B35f24aCF7fC0487D01c8d5690a60DBa07' // When - const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT)[3] }) + const result = getActiveSubMenuItem({ pathname, menuItem: menuConfig(mockT, false, undefined)[3] }) // Then - expect(result).toEqual(menuConfig(mockT)[3].items[1]) + expect(result).toEqual(menuConfig(mockT, false, undefined)[3].items[1]) }) + + it.todo('should return items with supportChainId') }) diff --git a/src/components/GlobalCheckClaimStatus/GalaxyNFTClaimModal.tsx b/src/components/GlobalCheckClaimStatus/GalaxyNFTClaimModal.tsx index 953a34a4f..03245d0ce 100644 --- a/src/components/GlobalCheckClaimStatus/GalaxyNFTClaimModal.tsx +++ b/src/components/GlobalCheckClaimStatus/GalaxyNFTClaimModal.tsx @@ -1,15 +1,9 @@ -import { useEffect, useState } from 'react' -import { AutoRenewIcon, Box, Button, Flex, InjectedModalProps, Modal, Text, TwitterIcon } from '@pancakeswap/uikit' -import styled from 'styled-components' +import { Box, Button, Flex, InjectedModalProps, Modal, Text, TwitterIcon } from '@pancakeswap/uikit' import confetti from 'canvas-confetti' import { useTranslation } from 'contexts/Localization' import delay from 'lodash/delay' -import { useGalaxyNFTClaimingContract } from 'hooks/useContract' -import request, { gql } from 'graphql-request' -import { GALAXY_NFT_CAMPAIGN_ID } from 'config/constants' -import useToast from 'hooks/useToast' -import { GALAXY_NFT_CLAIMING_API } from 'config/constants/endpoints' -import { useWeb3React } from '@web3-react/core' +import { useEffect } from 'react' +import styled from 'styled-components' const NFTImage = styled.img` border-radius: 12px; @@ -31,53 +25,8 @@ const showConfetti = () => { }) } -const GalaxyNFTClaimModal: React.FC = ({ onDismiss, cid }) => { +const GalaxyNFTClaimModal: React.FC = ({ onDismiss }) => { const { t } = useTranslation() - const { account } = useWeb3React() - const [isLoading, setIsLoading] = useState(false) - const galaxyNFTClaimingContract = useGalaxyNFTClaimingContract() - const { toastSuccess, toastError } = useToast() - - const handleClick = async () => { - setIsLoading(true) - try { - const { prepareParticipate } = await request( - GALAXY_NFT_CLAIMING_API, - gql` - mutation claim($campaignID: ID!, $address: String!) { - prepareParticipate(input: { signature: "", campaignID: $campaignID, address: $address }) { - allow - disallowReason - signature - spaceStation - mintFuncInfo { - verifyIDs - nftCoreAddress - } - } - } - `, - { campaignID: GALAXY_NFT_CAMPAIGN_ID, address: account }, - ) - const { allow, disallowReason, mintFuncInfo, signature } = prepareParticipate - if (!allow) { - console.error('Claim failed, disallow reason = ', disallowReason) - toastError(t('Failed to claim'), disallowReason) - } else { - await galaxyNFTClaimingContract.claim( - cid, - mintFuncInfo.nftCoreAddress, - mintFuncInfo.verifyIDs[0], - cid, - account, - signature, - ) - toastSuccess(t('Success!')) - } - } finally { - onDismiss?.() - } - } useEffect(() => { delay(showConfetti, 100) @@ -114,13 +63,6 @@ const GalaxyNFTClaimModal: React.FC = ({ o {t('Learn More')} - ) diff --git a/src/components/GlobalCheckClaimStatus/index.tsx b/src/components/GlobalCheckClaimStatus/index.tsx index dd81231aa..a72cd8f32 100644 --- a/src/components/GlobalCheckClaimStatus/index.tsx +++ b/src/components/GlobalCheckClaimStatus/index.tsx @@ -1,14 +1,5 @@ -import { useEffect, useRef, useState } from 'react' -import { useRouter } from 'next/router' -import { useModal } from '@pancakeswap/uikit' import { useWeb3React } from '@web3-react/core' -import dynamic from 'next/dynamic' -import request, { gql } from 'graphql-request' -import { GALAXY_NFT_CAMPAIGN_ID } from 'config/constants' -import { GALAXY_NFT_CLAIMING_API } from 'config/constants/endpoints' -import { useERC721 } from 'hooks/useContract' - -const GalaxyNFTClaimModal = dynamic(() => import('./GalaxyNFTClaimModal'), { ssr: false }) +import { useEffect, useRef } from 'react' interface GlobalCheckClaimStatusProps { excludeLocations: string[] @@ -31,57 +22,22 @@ const GlobalCheckClaimStatus: React.FC = (props) => * * TODO: Put global checks in redux or make a generic area to house global checks */ -const GlobalCheckClaim: React.FC = ({ excludeLocations }) => { +const GlobalCheckClaim: React.FC = () => { const hasDisplayedModal = useRef(false) - const [cid, setCid] = useState(null) - const [canClaimNFT, setCanClaimNFT] = useState(false) - const [nftBalance, setNftBalance] = useState(999) // default high to avoid flashing modal - const galaxyNFTContract = useERC721('0x2aD5745b7aD37037339EDe18407bf9395DE2d97F', false) - const { account } = useWeb3React() - const { pathname } = useRouter() - const [onPresentModal] = useModal(, false, true, 'galaxyNFTClaimModal') - - // Check claim status - useEffect(() => { - const fetchClaimNftStatus = async () => { - try { - const { campaign } = await request( - GALAXY_NFT_CLAIMING_API, - gql` - query checkEligibilityForGalaxyNFT($campaignId: ID!, $address: String!) { - campaign(id: $campaignId) { - numberID - creds { - eligible(address: $address) - } - } - } - `, - { campaignId: GALAXY_NFT_CAMPAIGN_ID, address: account }, - ) - const balance = await galaxyNFTContract.balanceOf(account) - setNftBalance(balance.toNumber()) - setCanClaimNFT(campaign.creds[0].eligible === 1) - setCid(campaign.numberID) - } catch (error) { - console.error('checkEligibilityForGalaxyNFT failed', error) - } - } - if (account) { - fetchClaimNftStatus() - } - }, [account, galaxyNFTContract]) - - // Check if we need to display the modal - useEffect(() => { - const matchesSomeLocations = excludeLocations.some((location) => pathname.includes(location)) - - if (canClaimNFT && !matchesSomeLocations && !hasDisplayedModal.current && nftBalance === 0) { - onPresentModal() - hasDisplayedModal.current = true - } - }, [pathname, excludeLocations, hasDisplayedModal, onPresentModal, canClaimNFT, nftBalance]) + const { account } = useWeb3React() + // const { pathname } = useRouter() + // const [onPresentModal] = useModal(, false, true, 'galaxyNFTClaimModal') + + // // Check if we need to display the modal + // useEffect(() => { + // const matchesSomeLocations = excludeLocations.some((location) => pathname.includes(location)) + + // if (canClaimNFT && !matchesSomeLocations && !hasDisplayedModal.current && nftBalance === 0) { + // onPresentModal() + // hasDisplayedModal.current = true + // } + // }, [pathname, excludeLocations, hasDisplayedModal, onPresentModal, canClaimNFT, nftBalance]) // Reset the check flag when account changes useEffect(() => { diff --git a/src/components/Menu/UserMenu/WalletInfo.tsx b/src/components/Menu/UserMenu/WalletInfo.tsx index ffbb4f4e9..bab5c3a46 100644 --- a/src/components/Menu/UserMenu/WalletInfo.tsx +++ b/src/components/Menu/UserMenu/WalletInfo.tsx @@ -1,6 +1,6 @@ import { Box, Button, Flex, InjectedModalProps, LinkExternal, Message, Skeleton, Text } from '@pancakeswap/uikit' import { useWeb3React } from '@web3-react/core' -import tokens from 'config/constants/tokens' +import { CAKE } from 'config/constants/tokens' import { FetchStatus } from 'config/constants/types' import { useTranslation } from 'contexts/Localization' import useAuth from 'hooks/useAuth' @@ -17,9 +17,9 @@ interface WalletInfoProps { const WalletInfo: React.FC = ({ hasLowBnbBalance, onDismiss }) => { const { t } = useTranslation() - const { account } = useWeb3React() + const { account, chainId } = useWeb3React() const { balance, fetchStatus } = useGetBnbBalance() - const { balance: cakeBalance, fetchStatus: cakeFetchStatus } = useTokenBalance(tokens.cake.address) + const { balance: cakeBalance, fetchStatus: cakeFetchStatus } = useTokenBalance(CAKE[chainId]?.address) const { logout } = useAuth() const handleLogout = () => { diff --git a/src/components/Menu/UserMenu/WalletWrongNetwork.tsx b/src/components/Menu/UserMenu/WalletWrongNetwork.tsx index 5eb2c22f3..84629755c 100644 --- a/src/components/Menu/UserMenu/WalletWrongNetwork.tsx +++ b/src/components/Menu/UserMenu/WalletWrongNetwork.tsx @@ -4,6 +4,7 @@ import { Button, Text, Link, HelpIcon } from '@pancakeswap/uikit' import { setupNetwork } from 'utils/wallet' import { useWeb3React } from '@web3-react/core' import { InjectedConnector } from '@web3-react/injected-connector' +import { ChainId } from '@pancakeswap/sdk' const StyledLink = styled(Link)` width: 100%; @@ -21,7 +22,7 @@ const WalletWrongNetwork: React.FC = ({ onDismiss }) => const { connector, library } = useWeb3React() const handleSwitchNetwork = async (): Promise => { - await setupNetwork(library) + await setupNetwork(ChainId.BSC, library) onDismiss?.() } diff --git a/src/components/Menu/config/config.ts b/src/components/Menu/config/config.ts index c5655ec20..a064819d0 100644 --- a/src/components/Menu/config/config.ts +++ b/src/components/Menu/config/config.ts @@ -16,146 +16,157 @@ import { nftsBaseUrl } from 'views/Nft/market/constants' import { perpLangMap } from 'utils/getPerpetualLanguageCode' import { perpTheme } from 'utils/getPerpetualTheme' import { DropdownMenuItems } from '@pancakeswap/uikit/src/components/DropdownMenu/types' +import { ChainId } from '@pancakeswap/sdk' export type ConfigMenuDropDownItemsType = DropdownMenuItems & { hideSubNav?: boolean } export type ConfigMenuItemsType = Omit & { hideSubNav?: boolean } & { items?: ConfigMenuDropDownItemsType[] } -const config: (t: ContextApi['t'], isDark: boolean, languageCode?: string) => ConfigMenuItemsType[] = ( - t, - isDark, - languageCode, -) => [ - { - label: t('Trade'), - icon: SwapIcon, - fillIcon: SwapFillIcon, - href: '/swap', - showItemsOnMobile: false, - items: [ - { - label: t('Swap'), - href: '/swap', - }, - { - label: t('Limit'), - href: '/limit-orders', - }, - { - label: t('Liquidity'), - href: '/liquidity', - }, - { - label: t('Perpetual'), - href: `https://perp.pancakeswap.finance/${perpLangMap(languageCode)}/futures/BTCUSDT?theme=${perpTheme( - isDark, - )}`, - type: DropdownMenuItemType.EXTERNAL_LINK, - }, - // { - // label: t('Transfer'), - // href: '/transfer', - // }, - ], - }, - { - label: t('Earn'), - href: '/farms', - icon: EarnIcon, - fillIcon: EarnFillIcon, - items: [ - { - label: t('Farms'), - href: '/farms', - }, - { - label: t('Pools'), - href: '/pools', - }, - ], - }, - { - label: t('Win'), - href: '/prediction', - icon: TrophyIcon, - fillIcon: TrophyFillIcon, - items: [ - { - label: t('Trading Competition'), - href: '/competition', - hideSubNav: true, - }, - { - label: t('Prediction (BETA)'), - href: '/prediction', - }, - { - label: t('Lottery'), - href: '/lottery', - }, - ], - }, - { - label: t('NFT'), - href: `${nftsBaseUrl}`, - icon: NftIcon, - fillIcon: NftFillIcon, - items: [ - { - label: t('Overview'), - href: `${nftsBaseUrl}`, - }, - { - label: t('Collections'), - href: `${nftsBaseUrl}/collections`, - }, - { - label: t('Activity'), - href: `${nftsBaseUrl}/activity`, - }, - ], - }, - { - label: '', - href: '/info', - icon: MoreIcon, - hideSubNav: true, - items: [ - { - label: t('Info'), - href: '/info', - }, - { - label: t('IFO'), - href: '/ifo', - }, - { - label: t('Voting'), - href: '/voting', - }, - { - type: DropdownMenuItemType.DIVIDER, - }, - { - label: t('Leaderboard'), - href: '/teams', - }, - { - type: DropdownMenuItemType.DIVIDER, - }, - { - label: t('Blog'), - href: 'https://medium.com/pancakeswap', - type: DropdownMenuItemType.EXTERNAL_LINK, - }, - { - label: t('Docs'), - href: 'https://docs.pancakeswap.finance', - type: DropdownMenuItemType.EXTERNAL_LINK, - }, - ], - }, -] +const filterItemBySupportChainId = (chainId) => (items) => + !chainId || !items.supportChainIds ? true : items.supportChainIds?.includes(chainId) + +const config: ( + t: ContextApi['t'], + isDark: boolean, + languageCode?: string, + chainId?: number, +) => ConfigMenuItemsType[] = (t, isDark, languageCode, chainId) => + [ + { + label: t('Trade'), + icon: SwapIcon, + fillIcon: SwapFillIcon, + href: '/swap', + showItemsOnMobile: false, + items: [ + { + label: t('Swap'), + href: '/swap', + }, + { + label: t('Limit'), + href: '/limit-orders', + supportChainIds: [ChainId.BSC], + }, + { + label: t('Liquidity'), + href: '/liquidity', + }, + { + label: t('Perpetual'), + href: `https://perp.pancakeswap.finance/${perpLangMap(languageCode)}/futures/BTCUSDT?theme=${perpTheme( + isDark, + )}`, + type: DropdownMenuItemType.EXTERNAL_LINK, + }, + // { + // label: t('Transfer'), + // href: '/transfer', + // }, + ].filter(filterItemBySupportChainId(chainId)), + }, + { + label: t('Earn'), + href: '/farms', + icon: EarnIcon, + fillIcon: EarnFillIcon, + supportChainIds: [ChainId.BSC], + items: [ + { + label: t('Farms'), + href: '/farms', + }, + { + label: t('Pools'), + href: '/pools', + }, + ], + }, + { + label: t('Win'), + href: '/prediction', + icon: TrophyIcon, + fillIcon: TrophyFillIcon, + supportChainIds: [ChainId.BSC], + items: [ + { + label: t('Trading Competition'), + href: '/competition', + hideSubNav: true, + }, + { + label: t('Prediction (BETA)'), + href: '/prediction', + }, + { + label: t('Lottery'), + href: '/lottery', + }, + ], + }, + { + label: t('NFT'), + href: `${nftsBaseUrl}`, + icon: NftIcon, + fillIcon: NftFillIcon, + supportChainIds: [ChainId.BSC], + items: [ + { + label: t('Overview'), + href: `${nftsBaseUrl}`, + }, + { + label: t('Collections'), + href: `${nftsBaseUrl}/collections`, + }, + { + label: t('Activity'), + href: `${nftsBaseUrl}/activity`, + }, + ], + }, + { + label: '', + href: '/info', + icon: MoreIcon, + hideSubNav: true, + supportChainIds: [ChainId.BSC], + items: [ + { + label: t('Info'), + href: '/info', + }, + { + label: t('IFO'), + href: '/ifo', + }, + { + label: t('Voting'), + href: '/voting', + }, + { + type: DropdownMenuItemType.DIVIDER, + }, + { + label: t('Leaderboard'), + href: '/teams', + }, + { + type: DropdownMenuItemType.DIVIDER, + }, + { + label: t('Blog'), + href: 'https://medium.com/pancakeswap', + type: DropdownMenuItemType.EXTERNAL_LINK, + }, + { + label: t('Docs'), + href: 'https://docs.pancakeswap.finance', + type: DropdownMenuItemType.EXTERNAL_LINK, + }, + ], + }, + ].filter(filterItemBySupportChainId(chainId)) export default config diff --git a/src/components/Menu/hooks/useMenuItems.ts b/src/components/Menu/hooks/useMenuItems.ts index b4a1bca47..72a2d36fd 100644 --- a/src/components/Menu/hooks/useMenuItems.ts +++ b/src/components/Menu/hooks/useMenuItems.ts @@ -1,5 +1,6 @@ import { useMemo } from 'react' import { menuStatus } from '@pancakeswap/uikit' +import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useTheme } from 'styled-components' import { useTranslation } from '../../../contexts/Localization' import { useMenuItemsStatus } from './useMenuItemsStatus' @@ -10,12 +11,13 @@ export const useMenuItems = (): ConfigMenuItemsType[] => { t, currentLanguage: { code: languageCode }, } = useTranslation() + const { chainId } = useActiveWeb3React() const { isDark } = useTheme() const menuItemsStatus = useMenuItemsStatus() const menuItems = useMemo(() => { - return config(t, isDark, languageCode) - }, [t, isDark, languageCode]) + return config(t, isDark, languageCode, chainId) + }, [t, isDark, languageCode, chainId]) return useMemo(() => { if (menuItemsStatus && Object.keys(menuItemsStatus).length) { diff --git a/src/components/TokenImage/index.tsx b/src/components/TokenImage/index.tsx index cf4054c09..fffbeea80 100644 --- a/src/components/TokenImage/index.tsx +++ b/src/components/TokenImage/index.tsx @@ -4,8 +4,8 @@ import { TokenImage as UIKitTokenImage, ImageProps, } from '@pancakeswap/uikit' -import tokens from 'config/constants/tokens' -import { Token } from '@pancakeswap/sdk' +import { bscTokens } from 'config/constants/tokens' +import { Token, ETHER, ChainId } from '@pancakeswap/sdk' interface TokenPairImageProps extends Omit { primaryToken: Token @@ -13,7 +13,10 @@ interface TokenPairImageProps extends Omit { - const address = token.symbol === 'BNB' ? tokens.wbnb.address : token.address + const address = token === ETHER ? bscTokens.bnb.address : token.address + if (token.chainId !== ChainId.BSC) { + return `/images/${token.chainId}/tokens/${address}.png` + } return `/images/tokens/${address}.png` } diff --git a/src/config/__tests__/tokens.test.ts b/src/config/__tests__/tokens.test.ts index cb6341f83..6310cff67 100644 --- a/src/config/__tests__/tokens.test.ts +++ b/src/config/__tests__/tokens.test.ts @@ -1,7 +1,7 @@ import map from 'lodash/map' import omitBy from 'lodash/omitBy' import erc20ABI from 'config/abi/erc20.json' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { Token } from '@pancakeswap/sdk' import multicall from 'utils/multicall' @@ -9,7 +9,7 @@ import multicall from 'utils/multicall' // remove ONE because there are two tokens with the symbol ONE (Harmony ONE and BigONE) // remove HERO because there are two tokens with the symbol HERO (StepHero and Hero) const tokensToTest = omitBy( - tokens, + bscTokens, (token) => token.symbol.toLowerCase() === 'bnb' || token.symbol.toLowerCase() === 'one' || diff --git a/src/config/abi/galaxyNFTClaiming.json b/src/config/abi/galaxyNFTClaiming.json deleted file mode 100644 index d2f0c03f2..000000000 --- a/src/config/abi/galaxyNFTClaiming.json +++ /dev/null @@ -1,162 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "_cid", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_dummyId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_nftID", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "_sender", - "type": "address" - } - ], - "name": "EventClaim", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_cid", - "type": "uint256" - }, - { - "internalType": "contract IStarNFT", - "name": "_starNFT", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_dummyId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_powah", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_mintTo", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_signature", - "type": "bytes" - } - ], - "name": "claim", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_cid", - "type": "uint256" - }, - { - "internalType": "contract IStarNFT", - "name": "_starNFT", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_dummyId", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_powah", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_cap", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_mintTo", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_signature", - "type": "bytes" - } - ], - "name": "claimCapped", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "campaignFeeConfigs", - "outputs": [ - { - "internalType": "address", - "name": "erc20", - "type": "address" - }, - { - "internalType": "uint256", - "name": "erc20Fee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "platformFee", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "numMinted", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/src/config/constants/contracts.ts b/src/config/constants/contracts.ts index d7def4cdf..1f17c06ac 100644 --- a/src/config/constants/contracts.ts +++ b/src/config/constants/contracts.ts @@ -15,6 +15,7 @@ export default { 97: '0x5790c3534F30437641541a0FA04C992799602998', 56: '0x5aF6D33DE2ccEC94efb1bDF8f92Bd58085432d2c', }, + // TODO: multi multiCall: { 56: '0xfF6FD90A470Aaa0c1B8A54681746b07AcdFedc9B', 97: '0x8F3273Fb89B075b1645095ABaC6ed17B2d4Bc576', @@ -115,10 +116,6 @@ export default { 56: '0x787980da5491118C3cB33B21aB50c8c379D2C552', 97: '0x981aE96378e770DE44F89cD9175E708f9EDB70a9', }, - galaxyNftClaiming: { - 56: '0x2D18f2d27D50C9b4013DEBA3D54f60996bD8847E', - 97: '', - }, nftMarket: { 56: '0x17539cCa21C7933Df5c980172d22659B8C345C5A', 97: '0x7f9f37ddcaa33893f9beb3d8748c8d6bfbde6ab2', @@ -131,6 +128,7 @@ export default { 56: '0x0a8901b0E25DEb55A87524f0cC164E9644020EBA', 97: '0xfC0c3F11fDA72Cb9A56F28Ec8D44C0ae4B3ABF86', }, + // TODO: multi zap: { 56: '0xD4c4a7C55c9f7B3c48bafb6E8643Ba79F42418dF', 97: '0xD85835207054F25620109bdc745EC1D1f84F04e1', diff --git a/src/config/constants/endpoints.ts b/src/config/constants/endpoints.ts index 5085a9455..f962db662 100644 --- a/src/config/constants/endpoints.ts +++ b/src/config/constants/endpoints.ts @@ -21,5 +21,3 @@ export const GRAPH_HEALTH = 'https://api.thegraph.com/index-node/graphql' export const TC_MOBOX_SUBGRAPH = 'https://api.thegraph.com/subgraphs/name/pancakeswap/trading-competition-v3' export const TC_MOD_SUBGRAPH = 'https://api.thegraph.com/subgraphs/name/pancakeswap/trading-competition-v4' - -export const GALAXY_NFT_CLAIMING_API = 'https://graphigo.prd.galaxy.eco/query' diff --git a/src/config/constants/exchange.ts b/src/config/constants/exchange.ts index 4d1e63f75..0e9897ea7 100644 --- a/src/config/constants/exchange.ts +++ b/src/config/constants/exchange.ts @@ -1,25 +1,25 @@ import { ChainId, JSBI, Percent, Token } from '@pancakeswap/sdk' import { BigNumber } from '@ethersproject/bignumber' -import { mainnetTokens, testnetTokens } from './tokens' +import { bscTokens, bscTestnetTokens } from './tokens' import { ChainTokenList } from './types' export const ROUTER_ADDRESS = { - [ChainId.MAINNET]: '0x10ED43C718714eb63d5aA57B78B54704E256024E', - [ChainId.TESTNET]: '0xD99D1c33F9fC3444f8101754aBC46c52416550D1', + [ChainId.BSC]: '0x10ED43C718714eb63d5aA57B78B54704E256024E', + [ChainId.BSC_TESTNET]: '0xD99D1c33F9fC3444f8101754aBC46c52416550D1', } // used to construct intermediary pairs for trading export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { - [ChainId.MAINNET]: [ - mainnetTokens.wbnb, - mainnetTokens.cake, - mainnetTokens.busd, - mainnetTokens.usdt, - mainnetTokens.btcb, - mainnetTokens.eth, - mainnetTokens.usdc, + [ChainId.BSC]: [ + bscTokens.wbnb, + bscTokens.cake, + bscTokens.busd, + bscTokens.usdt, + bscTokens.btcb, + bscTokens.eth, + bscTokens.usdc, ], - [ChainId.TESTNET]: [testnetTokens.wbnb, testnetTokens.cake, testnetTokens.busd], + [ChainId.BSC_TESTNET]: [bscTestnetTokens.wbnb, bscTestnetTokens.cake, bscTestnetTokens.busd], } /** @@ -27,35 +27,35 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { * @example { [WBTC.address]: [renBTC], [renBTC.address]: [WBTC] } */ export const ADDITIONAL_BASES: { [chainId in ChainId]?: { [tokenAddress: string]: Token[] } } = { - [ChainId.MAINNET]: {}, + [ChainId.BSC]: {}, } /** * Some tokens can only be swapped via certain pairs, so we override the list of bases that are considered for these * tokens. - * @example [AMPL.address]: [DAI, WETH[ChainId.MAINNET]] + * @example [AMPL.address]: [DAI, WNATIVE[ChainId.BSC]] */ export const CUSTOM_BASES: { [chainId in ChainId]?: { [tokenAddress: string]: Token[] } } = { - [ChainId.MAINNET]: {}, + [ChainId.BSC]: {}, } // used for display in the default list when adding liquidity export const SUGGESTED_BASES: ChainTokenList = { - [ChainId.MAINNET]: [mainnetTokens.busd, mainnetTokens.cake, mainnetTokens.btcb], - [ChainId.TESTNET]: [testnetTokens.wbnb, testnetTokens.cake, testnetTokens.busd], + [ChainId.BSC]: [bscTokens.busd, bscTokens.cake, bscTokens.btcb], + [ChainId.BSC_TESTNET]: [bscTestnetTokens.wbnb, bscTestnetTokens.cake, bscTestnetTokens.busd], } // used to construct the list of all pairs we consider by default in the frontend export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = { - [ChainId.MAINNET]: [mainnetTokens.wbnb, mainnetTokens.dai, mainnetTokens.busd, mainnetTokens.usdt], - [ChainId.TESTNET]: [testnetTokens.wbnb, testnetTokens.cake, testnetTokens.busd], + [ChainId.BSC]: [bscTokens.wbnb, bscTokens.dai, bscTokens.busd, bscTokens.usdt], + [ChainId.BSC_TESTNET]: [bscTestnetTokens.wbnb, bscTestnetTokens.cake, bscTestnetTokens.busd], } export const PINNED_PAIRS: { readonly [chainId in ChainId]?: [Token, Token][] } = { - [ChainId.MAINNET]: [ - [mainnetTokens.cake, mainnetTokens.wbnb], - [mainnetTokens.busd, mainnetTokens.usdt], - [mainnetTokens.dai, mainnetTokens.usdt], + [ChainId.BSC]: [ + [bscTokens.cake, bscTokens.wbnb], + [bscTokens.busd, bscTokens.usdt], + [bscTokens.dai, bscTokens.usdt], ], } diff --git a/src/config/constants/farmAuctions.ts b/src/config/constants/farmAuctions.ts index 24baaf825..104568301 100644 --- a/src/config/constants/farmAuctions.ts +++ b/src/config/constants/farmAuctions.ts @@ -1,808 +1,811 @@ -import { ChainId } from '@pancakeswap/sdk' import getLpAddress from 'utils/getLpAddress' -import { CHAIN_ID } from './networks' -import tokens from './tokens' +import { bscTokens } from './tokens' import { FarmAuctionBidderConfig } from './types' -export const whitelistedBidders: FarmAuctionBidderConfig[] = - Number(CHAIN_ID) === ChainId.MAINNET - ? [ - // Those farms changed their project wallet address. - { - account: '0xA6D19C2A2EA13e9eF02d795155F6c335af764955', // Auction #19 - farmName: 'HAPPY-BNB', - tokenAddress: '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', - quoteToken: tokens.wbnb, - tokenName: 'HappyFans', - projectSite: 'https://happyfans.club/', - }, - { - account: '0x4eeD6e51544Ef967A24A86F318A6779ed85cF0e6', // Auction #23 - farmName: 'HAPPY-BNB', - tokenAddress: '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', - quoteToken: tokens.wbnb, - tokenName: 'HappyFans', - projectSite: 'https://happyfans.club/', - }, - { - account: '0xB8614FABf4bbA416b9dB620e12272AD63b14387E', // Auction #20 - farmName: '8PAY-BUSD', - tokenAddress: '0xfeea0bdd3d07eb6fe305938878c0cadbfa169042', - quoteToken: tokens.busd, - tokenName: '8PAY', - projectSite: 'https://8pay.network/', - }, - // Below farms was the latest. - { - account: '0x9Ed5a62535A5Dd2dB2d9bB21bAc42035Af47F630', - farmName: 'NAV-BNB', - tokenAddress: '0xBFEf6cCFC830D3BaCA4F6766a0d4AaA242Ca9F3D', - quoteToken: tokens.wbnb, - tokenName: 'Navcoin', - projectSite: 'https://navcoin.org/en', - }, - { - account: '0x33723811B0FCa2a751f3912B80603Fe11499D894', - farmName: 'WSG-BNB', - tokenAddress: '0xA58950F05FeA2277d2608748412bf9F802eA4901', - quoteToken: tokens.wbnb, - tokenName: 'Wall Street Games', - projectSite: 'https://wsg.gg/', - }, - { - account: '0xD1C35C3F5D9d373A3F7c0668Fbe75801886e060f', - farmName: 'SWIRGE-BNB', - tokenAddress: '0xe792f64C582698b8572AAF765bDC426AC3aEfb6B', - quoteToken: tokens.wbnb, - tokenName: 'Swirge Network', - projectSite: 'https://swirge.com/', - }, - { - account: '0x58092273a044D6e1d23B5095AE873F6E24E906ed', - farmName: 'rUSD-BUSD', - tokenAddress: '0x07663837218A003e66310a01596af4bf4e44623D', - quoteToken: tokens.busd, - tokenName: 'RAMP DEFI', - projectSite: 'https://www.rampdefi.com/', - }, - { - account: '0xfAd3B5FeAC1aAF86B3f66D105F2fa9607164D86b', - farmName: 'FEED-BNB', - tokenAddress: '0x67d66e8Ec1Fd25d98B3Ccd3B19B7dc4b4b7fC493', - quoteToken: tokens.wbnb, - tokenName: 'Feeder Finance', - projectSite: 'https://www.feeder.finance/', - }, - { - account: '0xfCcA771Dc22359E4D6e9e9daC743EAb38f51EECe', - farmName: 'BBT-BNB', - tokenAddress: '0xD48474E7444727bF500a32D5AbE01943f3A59A64', - quoteToken: tokens.wbnb, - tokenName: 'BitBook', - projectSite: 'https://www.bitbook.network/', - }, - { - account: '0xAe126B90d2835c5A2D720b0687EC59f59b768183', - farmName: 'WOW-BUSD', - tokenAddress: '0x4DA996C5Fe84755C80e108cf96Fe705174c5e36A', - quoteToken: tokens.busd, - tokenName: 'WOWswap', - projectSite: 'https://wowswap.io/', - }, - { - account: '0x88F0A6cb89909838d69E4E6e76eC21e2a7bdcA66', - farmName: 'BREW-BNB', - tokenAddress: '0x790Be81C3cA0e53974bE2688cDb954732C9862e1', - quoteToken: tokens.wbnb, - tokenName: 'CafeSwap Finance', - projectSite: 'https://app.cafeswap.finance/', - }, - { - account: '0x0Cf86283ad1a1B7D04669696eD13BAE3d5925a0a', - farmName: 'SAKE-BNB', - tokenAddress: '0x8BD778B12b15416359A227F0533Ce2D91844e1eD', - quoteToken: tokens.wbnb, - tokenName: 'SakeSwap', - projectSite: 'https://bsc.sakeswap.finance/', - }, - { - account: '0xCe059E8af96a654d4afe630Fa325FBF70043Ab11', - farmName: 'XBLZD-BNB', - tokenAddress: '0x9a946c3Cb16c08334b69aE249690C236Ebd5583E', - quoteToken: tokens.wbnb, - tokenName: 'Blizzard', - projectSite: 'https://www.blizzard.money/', - }, - { - account: '0x3069270fE50c6dc9c5D1B38Ec7b767B2FE7B981D', - farmName: 'HERO-BNB', - tokenAddress: '0xD40bEDb44C081D2935eebA6eF5a3c8A31A1bBE13', - quoteToken: tokens.wbnb, - tokenName: 'Metahero', - projectSite: 'https://metahero.io/', - }, - { - account: '0x46D8e47b9A6487FDAB0a700b269A452cFeED49Aa', - farmName: 'MCRN-BNB', - tokenAddress: '0xacb2d47827C9813AE26De80965845D80935afd0B', - quoteToken: tokens.wbnb, - tokenName: 'MacaronSwap', - projectSite: 'https://www.macaronswap.finance/', - }, - { - account: '0x1bA962acab22Be9e49C4cEBE7710c9201A72dFcc', - farmName: 'BABYCAKE-BNB', - tokenAddress: '0xdB8D30b74bf098aF214e862C90E647bbB1fcC58c', - quoteToken: tokens.wbnb, - tokenName: 'Babycake', - projectSite: 'https://babycake.app/', - }, - { - account: '0xCCcC0b22799E82A79007814Dbc6A194410DCcEA5', - farmName: 'BMON-BNB', - tokenAddress: '0x08ba0619b1e7A582E0BCe5BBE9843322C954C340', - quoteToken: tokens.wbnb, - tokenName: 'Binamon', - projectSite: 'https://binamon.org/', - }, - { - account: '0x71eE6DE14c90700eE06C81aaBdBacD684cfe30fe', - farmName: 'BMON-BUSD', - tokenAddress: '0x08ba0619b1e7A582E0BCe5BBE9843322C954C340', - quoteToken: tokens.busd, - tokenName: 'Binamon', - projectSite: 'https://binamon.org/', - }, - { - account: '0x6cfA3ff4e96abe93a290dc3d7A911A483C194758', - farmName: 'ANY-BNB', - tokenAddress: '0xF68C9Df95a18B2A5a5fa1124d79EEEffBaD0B6Fa', - quoteToken: tokens.wbnb, - tokenName: 'Anyswap', - projectSite: 'https://anyswap.exchange/', - }, - { - account: '0xe596470D291Cb2D32ec111afC314B07006690c72', - farmName: 'PHX-BNB', - tokenAddress: '0xac86e5f9bA48d680516df50C72928c2ec50F3025', - quoteToken: tokens.wbnb, - tokenName: 'Phoenix Finance', - projectSite: 'https://www.phoenixprotocol.net/', - }, - { - account: '0x8f8c77987C0ea9dd2400383b623d9cbcBbAf98CF', - farmName: 'GMR-BNB', - tokenAddress: '0x0523215DCafbF4E4aA92117d13C6985a3BeF27D7', - quoteToken: tokens.wbnb, - tokenName: 'GMR Finance', - projectSite: 'https://www.gmr.finance/', - }, - { - account: '0x786B313b01A25eddbF7f7461b48D60AF680d758C', - farmName: 'BP-BNB', - tokenAddress: '0xACB8f52DC63BB752a51186D1c55868ADbFfEe9C1', - quoteToken: tokens.wbnb, - tokenName: 'BunnyPark', - projectSite: 'https://www.bunnypark.com/', - }, - { - account: '0x70d7eCEE276Ad5fDFc91B3C30d2c1cDb9dD442Fb', - farmName: 'DPET-BNB', - tokenAddress: '0xfb62AE373acA027177D1c18Ee0862817f9080d08', - quoteToken: tokens.wbnb, - tokenName: 'MyDefiPet', - projectSite: 'https://mydefipet.com/', - }, - { - account: '0x8aC06b55C9812e3E574CF5A5F3b49619dF33099C', - farmName: 'NMX-BUSD', - tokenAddress: '0xd32d01A43c869EdcD1117C640fBDcfCFD97d9d65', - quoteToken: tokens.busd, - tokenName: 'Nominex', - projectSite: 'https://nominex.io/', - }, - { - account: '0xd27E57Ff5dD3d78B03c85e2A2bB8dc37E67c5140', - farmName: 'POOLZ-BNB', - tokenAddress: '0x77018282fD033DAF370337A5367E62d8811Bc885', - quoteToken: tokens.wbnb, - tokenName: 'Poolz Finance', - projectSite: 'https://poolz.finance/', - }, - { - account: '0x0767a2f9c644b364Bc88Eea5a535afE506Ba6802', - farmName: 'ODDZ-BNB', - tokenAddress: '0xCD40F2670CF58720b694968698A5514e924F742d', - quoteToken: tokens.wbnb, - tokenName: 'Oddz Finance', - projectSite: 'https://oddz.fi', - }, - { - account: '0x2B6b2701d7F7b65BA2E1ec2d2dAa17d46B85A4fe', - farmName: 'UBXT-BUSD', - tokenAddress: '0xBbEB90cFb6FAFa1F69AA130B7341089AbeEF5811', - quoteToken: tokens.busd, - tokenName: 'UpBots', - projectSite: 'https://upbots.com/', - }, - { - account: '0x875831249bA511a6f1E49c84D66E1A6F5601f7C6', - farmName: 'DND-BUSD', - tokenAddress: '0x14c358b573a4cE45364a3DBD84BBb4Dae87af034', - quoteToken: tokens.busd, - tokenName: 'DungeonSwap', - projectSite: 'https://dungeonswap.app/', - }, - { - account: '0xb7d303BbaE2573513801C5F94aE0B61Fa5b3426F', - farmName: 'ZOON-BNB', - tokenAddress: '0x9D173E6c594f479B4d47001F8E6A95A7aDDa42bC', - quoteToken: tokens.wbnb, - tokenName: 'CryptoZoon', - projectSite: 'https://cryptozoon.io/', - }, - { - account: '0x22d56946c6cc1d4ed09f02858ddb990fcc981c55', - farmName: 'HGET-BUSD', - tokenAddress: '0xC7d8D35EBA58a0935ff2D5a33Df105DD9f071731', - quoteToken: tokens.busd, - tokenName: 'Hedget', - projectSite: 'https://www.hedget.com/', - }, - { - account: '0x027D50F36fe3b64630170B3ba82FC64BfC9bc088', - farmName: 'FAN-BNB', - tokenAddress: '0xFAc3A1ED2480Da8F5c34576C0Da13F245239717d', - quoteToken: tokens.wbnb, - tokenName: 'Fanadise', - projectSite: 'https://fanadise.com/', - }, - { - account: '0x73f9eb8eB7109b171396C8cbffcb29839c8b3064', - farmName: 'PKMON-BUSD', - tokenAddress: '0x609D183Fb91a0fce59550b62ab7d2c931b0Bb1BE', - quoteToken: tokens.busd, - tokenName: 'PolkaMonster', - projectSite: 'https://polkamonster.game/', - }, - { - account: '0x88Dba2cF8911A80cc50A1B392b5fF6b47B930330', - farmName: 'SFUND-BNB', - tokenAddress: '0x477bC8d23c634C154061869478bce96BE6045D12', - quoteToken: tokens.wbnb, - tokenName: 'Seedify', - projectSite: 'https://launchpad.seedify.fund/', - }, - { - account: '0xf1dD352EF3a94F60b3047B607C2Bd976401F538c', - farmName: 'GNT-BNB', - tokenAddress: '0xF750A26EB0aCf95556e8529E72eD530f3b60f348', - quoteToken: tokens.wbnb, - tokenName: 'GreenTrust', - projectSite: 'https://www.greentrusttoken.com/', - }, - { - account: '0x3992D7D9Ed721257d8bD7501d280b857eD7F9C24', - farmName: 'TT-BUSD', - tokenAddress: '0x990E7154bB999FAa9b2fa5Ed29E822703311eA85', - quoteToken: tokens.busd, - tokenName: 'ThunderCore', - projectSite: 'https://www.thundercore.com/', - }, - { - account: '0x2Ef317299888DD4a4F57FFf99FF2685D544fEAf1', - farmName: 'TT-BNB', - tokenAddress: '0x990E7154bB999FAa9b2fa5Ed29E822703311eA85', - quoteToken: tokens.wbnb, - tokenName: 'ThunderCore', - projectSite: 'https://www.thundercore.com/', - }, - { - account: '0xB9a32da7F33731FfDa8e7ecCB91325eee8A524AC', - farmName: 'SMG-BNB', - tokenAddress: '0x6bfd576220e8444CA4Cc5f89Efbd7f02a4C94C16', - quoteToken: tokens.wbnb, - tokenName: 'Smaugs NFT', - projectSite: 'https://smaugs.com', - }, - { - account: '0x5ed6B80F0e8b1c7fdB783202d4a926BbED2d49ee', - farmName: 'TENFI-BNB', - tokenAddress: '0xd15C444F1199Ae72795eba15E8C1db44E47abF62', - quoteToken: tokens.wbnb, - tokenName: 'TEN Finance', - projectSite: 'https://ten.finance/', - }, - { - account: '0x75015B56dA228A5367d313866f6520495344C65c', - farmName: 'BNX-BUSD', - tokenAddress: '0x8C851d1a123Ff703BD1f9dabe631b69902Df5f97', - quoteToken: tokens.busd, - tokenName: 'BinaryX', - projectSite: 'https://www.binaryx.pro/#/', - }, - { - account: '0xCbD932aC66f645a3764733aACD30Ce50e522Fac1', - farmName: 'DVI-BNB', - tokenAddress: '0x758FB037A375F17c7e195CC634D77dA4F554255B', - quoteToken: tokens.wbnb, - tokenName: 'Dvision', - projectSite: 'https://dvision.network/', - }, - { - account: '0xeA96c1970b9E3d4258620F68Af95ddDEB5fbD68F', - farmName: 'SALE-BNB', - tokenAddress: '0x97bb08ba41f033beaac315169fc566ac9e0daf52', - quoteToken: tokens.wbnb, - tokenName: 'DxSale Network', - projectSite: 'https://dxsale.app', - }, - { - account: '0xaDB2d11817Cd16595E4454aD03F95575c3B388f2', - farmName: 'MONI-BNB', - tokenAddress: '0x9573c88ae3e37508f87649f87c4dd5373c9f31e0', - quoteToken: tokens.wbnb, - tokenName: 'Monsta Infinite', - projectSite: 'https://monstainfinite.com/', - }, - { - account: '0xDa6e741A7f7d4d88d4210340069348704FDf21bf', - farmName: 'PROS-BNB', - tokenAddress: '0xed8c8aa8299c10f067496bb66f8cc7fb338a3405', - quoteToken: tokens.wbnb, - tokenName: 'Prosper', - projectSite: 'https://prosper.so/', - }, - { - account: '0xB651A851819638Cb120A46Db0E01Fa89006eE290', - farmName: 'CART-BNB', - tokenAddress: '0x5c8c8d560048f34e5f7f8ad71f2f81a89dbd273e', - quoteToken: tokens.wbnb, - tokenName: 'Cryptoart.ai', - projectSite: 'https://cryptoart.ai/', - }, - { - account: '0x73a4C2d21282dd9f9f2DF2aD3e06fd25aB487C9c', - farmName: 'XWIN-BNB', - tokenAddress: '0xd88ca08d8eec1E9E09562213Ae83A7853ebB5d28', - quoteToken: tokens.wbnb, - tokenName: 'xWIN Finance', - projectSite: 'https://xwin.finance/', - }, - { - account: '0x7Db4456a73a9C94a381d244E9dfC76E83C05913E', - farmName: 'SWAPP-BNB', - tokenAddress: '0x0efe961c733ff46ce34c56a73eba0c6a0e18e0f5', - quoteToken: tokens.wbnb, - tokenName: 'Swapp Protocol', - projectSite: 'https://swapp.ee', - }, - { - account: '0xB93A33f4cA46c1E1D65387313706cB8728B75703', - farmName: 'AIRT-BNB', - tokenAddress: '0x016cf83732f1468150d87dcc5bdf67730b3934d3', - quoteToken: tokens.wbnb, - tokenName: 'AirNFTs', - projectSite: 'https://airnfts.com/', - }, - { - account: '0x377056416332d017D2c2d140A097Ba8c2872bb60', - farmName: 'XMS-BNB', - tokenAddress: '0x7859b01bbf675d67da8cd128a50d155cd881b576', - quoteToken: tokens.wbnb, - tokenName: 'Mars Ecosystem', - projectSite: 'https://marsecosystem.com/', - }, - { - account: '0x6ff9B88eb94A976b0e1Db7713d8D765B8bE437a7', - farmName: 'LIGHT-BNB', - tokenAddress: '0x037838b556d9c9d654148a284682C55bB5f56eF4', - quoteToken: tokens.wbnb, - tokenName: 'Lightning', - projectSite: 'https://lightningprotocol.finance/', - }, - { - account: '0x235540Bd639308E51Efa89AbF2A9AF8bC1DEc877', - farmName: 'GENS-BUSD', - tokenAddress: '0x2CD14cbA3F26254beeD1d78158cd2B6F91809600', - quoteToken: tokens.busd, - tokenName: 'Genshiro', - projectSite: 'https://genshiro.equilibrium.io/en', - }, - { - account: '0xc55A7183F6D060271010A4441c106f6a81D46E34', - farmName: 'WSPP-BNB', - tokenAddress: '0x46d502fac9aea7c5bc7b13c8ec9d02378c33d36f', - quoteToken: tokens.wbnb, - tokenName: 'WolfSafePoorPeople', - projectSite: 'https://wolfsafepoorpeople.com', - }, - { - account: '0xC1d204015268CD808B765f024e04CE01d5Bff58D', - farmName: 'SHEESHA-BNB', - tokenAddress: '0x232fb065d9d24c34708eedbf03724f2e95abe768', - quoteToken: tokens.wbnb, - tokenName: 'Sheesha Finance', - projectSite: 'https://sheeshafinance.io', - }, - { - account: '0xb2bef43cb487bFc89770e2e88C23f6a2163133EE', - farmName: 'BSCS-BNB', - tokenAddress: '0xbcb24afb019be7e93ea9c43b7e22bb55d5b7f45d', - quoteToken: tokens.wbnb, - tokenName: 'BSCStation', - projectSite: 'https://bscstation.finance/', - }, - { - account: '0x47e947F01A17F8004D486fC7E37222B205a4c20b', - farmName: 'ARV-BNB', - tokenAddress: '0x6679eB24F59dFe111864AEc72B443d1Da666B360', - quoteToken: tokens.wbnb, - tokenName: 'Ariva', - projectSite: 'https://ariva.digital/', - }, - { - account: '0x8595c4Ad15D51c5Bf920c249869Ec5b3250c2D4d', - farmName: 'ULTI-BNB', - tokenAddress: '0x42BFE4A3E023f2C90aEBFfbd9B667599Fa38514F', - quoteToken: tokens.wbnb, - tokenName: 'ULTI Arena', - projectSite: 'https://ultiarena.com', - }, - { - account: '0x1723D77Afde343323b769271a83d5Aecada25e01', - farmName: 'ZOO-BUSD', - tokenAddress: '0x1D229B958D5DDFca92146585a8711aECbE56F095', - quoteToken: tokens.busd, - tokenName: 'ZOO Crypto World', - projectSite: 'https://zoogame.finance/', - }, - { - account: '0x8b519cD36b6a3179a4C560FcE987203E33df0366', - farmName: 'HERA-BNB', - tokenAddress: '0x49c7295ff86eabf5bf58c6ebc858db4805738c01', - quoteToken: tokens.wbnb, - tokenName: 'Hero Arena', - projectSite: 'https://heroarena.app/', - }, - { - account: '0xaCc34268f5D7Cb9B11BfB1ba4D8bD2bc2B49EE4E', - farmName: 'DPS-BNB', - tokenAddress: '0xf275e1AC303a4C9D987a2c48b8E555A77FeC3F1C', - quoteToken: tokens.wbnb, - tokenName: 'DEEPSPACE', - projectSite: 'https://deepspace.game', - }, - { - account: '0x050F559cD756cA09FC46988B6cf19ebF01256268', - farmName: 'BCOIN-BUSD', - tokenAddress: '0x00e1656e45f18ec6747F5a8496Fd39B50b38396D', - quoteToken: tokens.busd, - tokenName: 'Bomb Crypto', - projectSite: 'https://bombcrypto.io/', - }, - { - account: '0x6524b3B11979D5b5c354D5A804be9711d767f38F', - farmName: 'XEUS-BUSD', - tokenAddress: '0x4E141769366634D9c4e498257Fa7EC204d22b634', - quoteToken: tokens.busd, - tokenName: 'XEUS', - projectSite: 'https://xeus.finance/', - }, - { - account: '0x1Aa800bE7e9829DDF97C54EF750F5E42C2a6a884', - farmName: 'SHARPEI-BNB', - tokenAddress: '0xfE3AF7376e412a377358d5894C790bB3e00D0dc1', - quoteToken: tokens.wbnb, - tokenName: 'Shar Pei', - projectSite: 'https://sharpeitoken.io/', - }, - { - account: '0x2c32E56756964aCdB650521c1F10bdb939D5Ff7B', - farmName: 'PID-BUSD', - tokenAddress: '0x1215Ed20aa507578ca352E195016F289e7A17f3A', - quoteToken: tokens.busd, - tokenName: 'PIDAO', - projectSite: 'https://www.pidao.finance/', - }, - { - account: '0x4AD72A0841808b431525de29a7781d948675bAC7', - farmName: 'HTD-BUSD', - tokenAddress: '0x5E2689412Fae5c29BD575fbe1d5C1CD1e0622A8f', - quoteToken: tokens.busd, - tokenName: 'HeroesTD', - projectSite: 'https://heroestd.io/', - }, - { - account: '0xFfD8457466bAa1f11Bb585c7fD772Ad1A8b82b64', - farmName: 'GMEE-BNB', - tokenAddress: '0x84e9a6F9D240FdD33801f7135908BfA16866939A', - quoteToken: tokens.wbnb, - tokenName: 'GAMEE', - projectSite: 'https://token.gamee.com/', - }, - { - account: '0x820E53c3198dB5904938Bec31B3Ec3864a754c31', - farmName: 'ANTEX-BUSD', - tokenAddress: '0xCA1aCAB14e85F30996aC83c64fF93Ded7586977C', - quoteToken: tokens.busd, - tokenName: 'Antex', - projectSite: 'https://antex.org/', - }, - { - account: '0x5905A1F7BAf19844874B8B16E5FC4cde639b7a32', - farmName: 'SIP-BUSD', - tokenAddress: '0x9e5965d28E8D44CAE8F9b809396E0931F9Df71CA', - quoteToken: tokens.busd, - tokenName: 'Space Sip', - projectSite: 'https://sip.space/', - }, - { - account: '0x20C99830967a18563D2D3eD51094aDD9FBE06e2A', - farmName: 'SDAO-BNB', - tokenAddress: '0x90ed8f1dc86388f14b64ba8fb4bbd23099f18240', - quoteToken: tokens.wbnb, - tokenName: 'SingularityDAO', - projectSite: 'https://app.singularitydao.ai/', - }, - { - account: '0x304dDD664C961141B9C11F0ab597244306e021F4', - farmName: '8PAY-BUSD', - tokenAddress: '0xfeea0bdd3d07eb6fe305938878c0cadbfa169042', - quoteToken: tokens.busd, - tokenName: '8PAY', - projectSite: 'https://8pay.network/', - }, - { - account: '0xb8Ce421729232eCD5DFc7BD0adFe1f4DAd9D9CcE', - farmName: 'BATH-BUSD', - tokenAddress: '0x0bc89aa98Ad94E6798Ec822d0814d934cCD0c0cE', - quoteToken: tokens.busd, - tokenName: 'Battle Hero', - projectSite: 'https://battlehero.io/', - }, - { - account: '0x3591b656D753226dE239d2b9A48221daf0751Fca', - farmName: 'HE-BNB', - tokenAddress: '0x20d39a5130f799b95b55a930e5b7ebc589ea9ed8', - quoteToken: tokens.wbnb, - tokenName: 'Heroes & Empires', - projectSite: 'https://heroesempires.com/', - }, - { - account: '0xCbEd1a5c8847de8B284f7cf5cf752b3b2E3b5112', - farmName: 'AOG-BUSD', - tokenAddress: '0x40C8225329Bd3e28A043B029E0D07a5344d2C27C', - quoteToken: tokens.busd, - tokenName: 'AgeOfGods', - projectSite: 'https://ageofgods.net/', - }, - { - account: '0xCb70F0B3791D05D0D2Aec36805fd2411a89f3aa1', - farmName: 'PRL-BUSD', - tokenAddress: '0xd07e82440A395f3F3551b42dA9210CD1Ef4f8B24', - quoteToken: tokens.busd, - tokenName: 'The Parallel', - projectSite: 'https://theparallel.io/', - }, - { - account: '0xe60035673BAFDaD24C5B14E9556F5793dFFb3362', - farmName: 'LOA-BUSD', - tokenAddress: '0x94b69263fca20119ae817b6f783fc0f13b02ad50', - quoteToken: tokens.busd, - tokenName: 'League of Ancients', - projectSite: 'https://leagueofancients.com/', - }, - { - account: '0x05Adabb0f3bff63F5f7712f05F04F509494A18F3', - farmName: 'HOTCROSS-BNB', - tokenAddress: '0x4fa7163e153419e0e1064e418dd7a99314ed27b6', - quoteToken: tokens.wbnb, - tokenName: 'Hot Cross', - projectSite: 'https://hotcross.com/', - }, - { - account: '0x8e762609CEa5Ddd3234B9d41Cf8D0d8b4f2581a6', - farmName: 'TEM-BUSD', - tokenAddress: '0x19e6BfC1A6e4B042Fb20531244D47E252445df01', - quoteToken: tokens.busd, - tokenName: 'TemplarDAO', - projectSite: 'https://templar.finance/', - }, - { - account: '0xE9ab352015928CBE21771564E97bDAA3F5fbCBAC', - farmName: 'GRAV-BUSD', - tokenAddress: '0xa6168c7e5eb7c5c379f3a1d7cf1073e09b2f031e', - quoteToken: tokens.busd, - tokenName: 'Graviton Zero', - projectSite: 'https://gravitonzero.com/', - }, - { - account: '0x5Be8ed8EbCF5215A45E84B864526EfdF6F584152', - farmName: 'BABY-BNB', - tokenAddress: '0x53e562b9b7e5e94b81f10e96ee70ad06df3d2657', - quoteToken: tokens.wbnb, - tokenName: 'BabySwap', - projectSite: 'https://home.babyswap.finance/', - }, - { - account: '0x73e60b46908319B17f1De07C5d38437BFf684E50', - farmName: 'GEAR-BNB', - tokenAddress: '0xb4404DaB7C0eC48b428Cf37DeC7fb628bcC41B36', - quoteToken: tokens.wbnb, - tokenName: 'MetaGear', - projectSite: 'https://metagear.game/', - }, - { - account: '0xF113b815e24Cc866137c4933b39fe2878ED1F2d2', - farmName: 'RDR-BUSD', - tokenAddress: '0x92da433da84d58dfe2aade1943349e491cbd6820', - quoteToken: tokens.busd, - tokenName: 'Rise of Defenders', - projectSite: 'https://risedefenders.io/', - }, - { - account: '0x38408A0D905930f44fe6C53321684824b22c30c5', - farmName: 'FIGHT-BUSD', - tokenAddress: '0x4f39c3319188A723003670c3F9B9e7EF991E52F3', - quoteToken: tokens.busd, - tokenName: 'Crypto Fight Club', - projectSite: 'https://www.cryptofightclub.io/', - }, - { - account: '0xadF88A1eDC8F15CeA27F2674ED2BA1382F46A8A5', - farmName: 'DOME-BNB', - tokenAddress: '0x475bfaa1848591ae0e6ab69600f48d828f61a80e', - quoteToken: tokens.wbnb, - tokenName: 'Everdome', - projectSite: 'https://everdome.io/', - }, - { - account: '0xdE78F42bff7EDF1e70450e7BCFd8aBCF94e3a65e', - farmName: 'TINC-BNB', - tokenAddress: '0x05ad6e30a855be07afa57e08a4f30d00810a402e', - quoteToken: tokens.wbnb, - tokenName: 'Tiny World', - projectSite: 'https://tinyworlds.io/', - }, - { - account: '0x71F36803139caC2796Db65F373Fb7f3ee0bf3bF9', - farmName: 'BLP-BUSD', - tokenAddress: '0xfe1d7f7a8f0bda6e415593a2e4f82c64b446d404', - quoteToken: tokens.busd, - tokenName: 'Bull Perks', - projectSite: 'https://bullperks.com/', - }, - { - account: '0x5735BB4e439474828235a5F4048eDf0240dcA7F2', - farmName: 'YEL-BNB', - tokenAddress: '0xd3b71117e6c1558c1553305b44988cd944e97300', - quoteToken: tokens.wbnb, - tokenName: 'YEL Token', - projectSite: 'https://yel.finance/', - }, - { - account: '0x638fBD99Fe8CC28535Fa05D3825a028c0a1E430d', - farmName: 'MNFT-BUSD', - tokenAddress: '0x36953b5ec00a13edceceb3af258d034913d2a79d', - quoteToken: tokens.busd, - tokenName: 'ManuFactory', - projectSite: 'https://manufactory.gg', - }, - { - account: '0x00b4565008cD3f71DECf5DCa5e8Ebfc859eED35B', - farmName: 'DFIAT-BUSD', - tokenAddress: '0xF64eD9Ad397A1Ae657F31131d4B189220A7f1cc7', - quoteToken: tokens.busd, - tokenName: 'DeFiato', - projectSite: 'https://defiato.com/', - }, - { - account: '0x7a837dE1Aa84E60273864025eaffecE8D9e51FFe', - farmName: 'HAPPY-BNB', - tokenAddress: '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', - quoteToken: tokens.wbnb, - tokenName: 'HappyFans', - projectSite: 'https://happyfans.club/', - }, - { - account: '0x0888406F1091D18e941F3Fe74ee0286963FFAc48', - farmName: 'WZRD-BUSD', - tokenAddress: '0xFa40d8FC324bcdD6Bbae0e086De886c571C225d4', - quoteToken: tokens.busd, - tokenName: 'Wizardia', - projectSite: 'https://wizardia.io/', - }, - { - account: '0x83e0dE1c6dD34e07D5b1BAF36b367e22C8b6fDdF', - farmName: 'XCN-BNB', - tokenAddress: '0x7324c7C0d95CEBC73eEa7E85CbAac0dBdf88a05b', - quoteToken: tokens.wbnb, - tokenName: 'Chain', - projectSite: 'https://chain.com/', - }, - { - account: '0x4D85770FD4d42060d3A8075eF781830954b5C93F', - farmName: 'eLunr-BUSD', - tokenAddress: '0x37807D4fbEB84124347B8899Dd99616090D3e304', - quoteToken: tokens.busd, - tokenName: 'LunarCrush', - projectSite: 'https://lunarcrush.com/', - }, - { - account: '0x4acD36243d2cdE7865CA13E827ede5fBFF1ADe3d', - farmName: 'ETM-BUSD', - tokenAddress: '0x75bDEd6BF44bb01527138673dCc064DBe3E7d96d', - quoteToken: tokens.busd, - tokenName: 'Etermon', - projectSite: 'https://etermon.io/', - }, - { - account: '0x3b8eA037356CfD867c2191FD11614FA97BAB2772', - farmName: 'NBT-USDT', - tokenAddress: '0x1D3437E570e93581Bd94b2fd8Fbf202d4a65654A', - quoteToken: tokens.usdt, - tokenName: 'NanoByte', - projectSite: 'https://www.nanobyte.finance/', - }, - { - account: '0xf2110Fb93F8Ed4528A5849C9fDEDC589349a07dc', - farmName: 'SB-USDT', - tokenAddress: '0xB7258450681f4aAd0ab24E336648d44A6696B30f', - quoteToken: tokens.usdt, - tokenName: 'DragonSB', - projectSite: 'https://dragonsb.finance/', - }, - { - account: '0x3846e7A1A5dEA3F43104ed89ff0E6FfD1Cc74b6E', - farmName: 'PEAK-BNB', - tokenAddress: '0x630d98424eFe0Ea27fB1b3Ab7741907DFFEaAd78', - quoteToken: tokens.wbnb, - tokenName: 'PEAKDEFI', - projectSite: 'https://peakdefi.com/', - }, - { - account: '0x6587515802FF7f9cD7442EAE8dfAE20f9d71306F', - farmName: 'SHELL-BUSD', - tokenAddress: '0x208cfEc94d2BA8B8537da7A9BB361c6baAD77272', - quoteToken: tokens.busd, - tokenName: 'SHELL', - projectSite: 'https://metaapesgame.com/', - }, - { - account: '0x1170852F4C69d458f6ef7375EF7fa7c74AdD3F04', - farmName: 'MHUNT-BNB', - tokenAddress: '0x2C717059b366714d267039aF8F59125CAdce6D8c', - quoteToken: tokens.wbnb, - tokenName: 'MHUNT', - projectSite: 'https://metashooter.gg/', - }, - { - account: '0x6a2d41c87c3F28C2C0b466424DE8e08FC2E23eDc', - farmName: 'AOG-CAKE', - tokenAddress: '0x40C8225329Bd3e28A043B029E0D07a5344d2C27C', - quoteToken: tokens.cake, - tokenName: 'AOG', - projectSite: 'https://ageofgods.net/', - }, - { - account: '0xe01935Ef7BEF076eE0257C4D5601940490a8d266', - farmName: 'XCAD-BUSD', - tokenAddress: '0x431e0cD023a32532BF3969CddFc002c00E98429d', - quoteToken: tokens.busd, - tokenName: 'XCAD', - projectSite: 'https://xcadnetwork.com/', - }, - ].map((bidderConfig) => ({ - ...bidderConfig, - lpAddress: getLpAddress(bidderConfig.tokenAddress, bidderConfig.quoteToken), - })) - : [] +export const whitelistedBidders: FarmAuctionBidderConfig[] = [ + // Those farms changed their project wallet address. + { + account: '0xA6D19C2A2EA13e9eF02d795155F6c335af764955', // Auction #19 + farmName: 'HAPPY-BNB', + tokenAddress: '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', + quoteToken: bscTokens.wbnb, + tokenName: 'HappyFans', + projectSite: 'https://happyfans.club/', + }, + { + account: '0x4eeD6e51544Ef967A24A86F318A6779ed85cF0e6', // Auction #23 + farmName: 'HAPPY-BNB', + tokenAddress: '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', + quoteToken: bscTokens.wbnb, + tokenName: 'HappyFans', + projectSite: 'https://happyfans.club/', + }, + { + account: '0xB8614FABf4bbA416b9dB620e12272AD63b14387E', // Auction #20 + farmName: '8PAY-BUSD', + tokenAddress: '0xfeea0bdd3d07eb6fe305938878c0cadbfa169042', + quoteToken: bscTokens.busd, + tokenName: '8PAY', + projectSite: 'https://8pay.network/', + }, + { + account: '0x6a2d41c87c3F28C2C0b466424DE8e08FC2E23eDc', // Auction #23 + farmName: 'BBT-BNB', + tokenAddress: '0xD48474E7444727bF500a32D5AbE01943f3A59A64', + quoteToken: bscTokens.wbnb, + tokenName: 'BitBook', + projectSite: 'https://www.bitbook.network/', + }, + // Below farms was the latest. + { + account: '0x9Ed5a62535A5Dd2dB2d9bB21bAc42035Af47F630', + farmName: 'NAV-BNB', + tokenAddress: '0xBFEf6cCFC830D3BaCA4F6766a0d4AaA242Ca9F3D', + quoteToken: bscTokens.wbnb, + tokenName: 'Navcoin', + projectSite: 'https://navcoin.org/en', + }, + { + account: '0x33723811B0FCa2a751f3912B80603Fe11499D894', + farmName: 'WSG-BNB', + tokenAddress: '0xA58950F05FeA2277d2608748412bf9F802eA4901', + quoteToken: bscTokens.wbnb, + tokenName: 'Wall Street Games', + projectSite: 'https://wsg.gg/', + }, + { + account: '0xD1C35C3F5D9d373A3F7c0668Fbe75801886e060f', + farmName: 'SWIRGE-BNB', + tokenAddress: '0xe792f64C582698b8572AAF765bDC426AC3aEfb6B', + quoteToken: bscTokens.wbnb, + tokenName: 'Swirge Network', + projectSite: 'https://swirge.com/', + }, + { + account: '0x58092273a044D6e1d23B5095AE873F6E24E906ed', + farmName: 'rUSD-BUSD', + tokenAddress: '0x07663837218A003e66310a01596af4bf4e44623D', + quoteToken: bscTokens.busd, + tokenName: 'RAMP DEFI', + projectSite: 'https://www.rampdefi.com/', + }, + { + account: '0xfAd3B5FeAC1aAF86B3f66D105F2fa9607164D86b', + farmName: 'FEED-BNB', + tokenAddress: '0x67d66e8Ec1Fd25d98B3Ccd3B19B7dc4b4b7fC493', + quoteToken: bscTokens.wbnb, + tokenName: 'Feeder Finance', + projectSite: 'https://www.feeder.finance/', + }, + { + account: '0xfCcA771Dc22359E4D6e9e9daC743EAb38f51EECe', + farmName: 'BBT-BNB', + tokenAddress: '0xD48474E7444727bF500a32D5AbE01943f3A59A64', + quoteToken: bscTokens.wbnb, + tokenName: 'BitBook', + projectSite: 'https://www.bitbook.network/', + }, + { + account: '0xAe126B90d2835c5A2D720b0687EC59f59b768183', + farmName: 'WOW-BUSD', + tokenAddress: '0x4DA996C5Fe84755C80e108cf96Fe705174c5e36A', + quoteToken: bscTokens.busd, + tokenName: 'WOWswap', + projectSite: 'https://wowswap.io/', + }, + { + account: '0x88F0A6cb89909838d69E4E6e76eC21e2a7bdcA66', + farmName: 'BREW-BNB', + tokenAddress: '0x790Be81C3cA0e53974bE2688cDb954732C9862e1', + quoteToken: bscTokens.wbnb, + tokenName: 'CafeSwap Finance', + projectSite: 'https://app.cafeswap.finance/', + }, + { + account: '0x0Cf86283ad1a1B7D04669696eD13BAE3d5925a0a', + farmName: 'SAKE-BNB', + tokenAddress: '0x8BD778B12b15416359A227F0533Ce2D91844e1eD', + quoteToken: bscTokens.wbnb, + tokenName: 'SakeSwap', + projectSite: 'https://bsc.sakeswap.finance/', + }, + { + account: '0xCe059E8af96a654d4afe630Fa325FBF70043Ab11', + farmName: 'XBLZD-BNB', + tokenAddress: '0x9a946c3Cb16c08334b69aE249690C236Ebd5583E', + quoteToken: bscTokens.wbnb, + tokenName: 'Blizzard', + projectSite: 'https://www.blizzard.money/', + }, + { + account: '0x3069270fE50c6dc9c5D1B38Ec7b767B2FE7B981D', + farmName: 'HERO-BNB', + tokenAddress: '0xD40bEDb44C081D2935eebA6eF5a3c8A31A1bBE13', + quoteToken: bscTokens.wbnb, + tokenName: 'Metahero', + projectSite: 'https://metahero.io/', + }, + { + account: '0x46D8e47b9A6487FDAB0a700b269A452cFeED49Aa', + farmName: 'MCRN-BNB', + tokenAddress: '0xacb2d47827C9813AE26De80965845D80935afd0B', + quoteToken: bscTokens.wbnb, + tokenName: 'MacaronSwap', + projectSite: 'https://www.macaronswap.finance/', + }, + { + account: '0x1bA962acab22Be9e49C4cEBE7710c9201A72dFcc', + farmName: 'BABYCAKE-BNB', + tokenAddress: '0xdB8D30b74bf098aF214e862C90E647bbB1fcC58c', + quoteToken: bscTokens.wbnb, + tokenName: 'Babycake', + projectSite: 'https://babycake.app/', + }, + { + account: '0xCCcC0b22799E82A79007814Dbc6A194410DCcEA5', + farmName: 'BMON-BNB', + tokenAddress: '0x08ba0619b1e7A582E0BCe5BBE9843322C954C340', + quoteToken: bscTokens.wbnb, + tokenName: 'Binamon', + projectSite: 'https://binamon.org/', + }, + { + account: '0x71eE6DE14c90700eE06C81aaBdBacD684cfe30fe', + farmName: 'BMON-BUSD', + tokenAddress: '0x08ba0619b1e7A582E0BCe5BBE9843322C954C340', + quoteToken: bscTokens.busd, + tokenName: 'Binamon', + projectSite: 'https://binamon.org/', + }, + { + account: '0x6cfA3ff4e96abe93a290dc3d7A911A483C194758', + farmName: 'ANY-BNB', + tokenAddress: '0xF68C9Df95a18B2A5a5fa1124d79EEEffBaD0B6Fa', + quoteToken: bscTokens.wbnb, + tokenName: 'Anyswap', + projectSite: 'https://anyswap.exchange/', + }, + { + account: '0xe596470D291Cb2D32ec111afC314B07006690c72', + farmName: 'PHX-BNB', + tokenAddress: '0xac86e5f9bA48d680516df50C72928c2ec50F3025', + quoteToken: bscTokens.wbnb, + tokenName: 'Phoenix Finance', + projectSite: 'https://www.phoenixprotocol.net/', + }, + { + account: '0x8f8c77987C0ea9dd2400383b623d9cbcBbAf98CF', + farmName: 'GMR-BNB', + tokenAddress: '0x0523215DCafbF4E4aA92117d13C6985a3BeF27D7', + quoteToken: bscTokens.wbnb, + tokenName: 'GMR Finance', + projectSite: 'https://www.gmr.finance/', + }, + { + account: '0x786B313b01A25eddbF7f7461b48D60AF680d758C', + farmName: 'BP-BNB', + tokenAddress: '0xACB8f52DC63BB752a51186D1c55868ADbFfEe9C1', + quoteToken: bscTokens.wbnb, + tokenName: 'BunnyPark', + projectSite: 'https://www.bunnypark.com/', + }, + { + account: '0x70d7eCEE276Ad5fDFc91B3C30d2c1cDb9dD442Fb', + farmName: 'DPET-BNB', + tokenAddress: '0xfb62AE373acA027177D1c18Ee0862817f9080d08', + quoteToken: bscTokens.wbnb, + tokenName: 'MyDefiPet', + projectSite: 'https://mydefipet.com/', + }, + { + account: '0x8aC06b55C9812e3E574CF5A5F3b49619dF33099C', + farmName: 'NMX-BUSD', + tokenAddress: '0xd32d01A43c869EdcD1117C640fBDcfCFD97d9d65', + quoteToken: bscTokens.busd, + tokenName: 'Nominex', + projectSite: 'https://nominex.io/', + }, + { + account: '0xd27E57Ff5dD3d78B03c85e2A2bB8dc37E67c5140', + farmName: 'POOLZ-BNB', + tokenAddress: '0x77018282fD033DAF370337A5367E62d8811Bc885', + quoteToken: bscTokens.wbnb, + tokenName: 'Poolz Finance', + projectSite: 'https://poolz.finance/', + }, + { + account: '0x0767a2f9c644b364Bc88Eea5a535afE506Ba6802', + farmName: 'ODDZ-BNB', + tokenAddress: '0xCD40F2670CF58720b694968698A5514e924F742d', + quoteToken: bscTokens.wbnb, + tokenName: 'Oddz Finance', + projectSite: 'https://oddz.fi', + }, + { + account: '0x2B6b2701d7F7b65BA2E1ec2d2dAa17d46B85A4fe', + farmName: 'UBXT-BUSD', + tokenAddress: '0xBbEB90cFb6FAFa1F69AA130B7341089AbeEF5811', + quoteToken: bscTokens.busd, + tokenName: 'UpBots', + projectSite: 'https://upbots.com/', + }, + { + account: '0x875831249bA511a6f1E49c84D66E1A6F5601f7C6', + farmName: 'DND-BUSD', + tokenAddress: '0x14c358b573a4cE45364a3DBD84BBb4Dae87af034', + quoteToken: bscTokens.busd, + tokenName: 'DungeonSwap', + projectSite: 'https://dungeonswap.app/', + }, + { + account: '0xb7d303BbaE2573513801C5F94aE0B61Fa5b3426F', + farmName: 'ZOON-BNB', + tokenAddress: '0x9D173E6c594f479B4d47001F8E6A95A7aDDa42bC', + quoteToken: bscTokens.wbnb, + tokenName: 'CryptoZoon', + projectSite: 'https://cryptozoon.io/', + }, + { + account: '0x22d56946c6cc1d4ed09f02858ddb990fcc981c55', + farmName: 'HGET-BUSD', + tokenAddress: '0xC7d8D35EBA58a0935ff2D5a33Df105DD9f071731', + quoteToken: bscTokens.busd, + tokenName: 'Hedget', + projectSite: 'https://www.hedget.com/', + }, + { + account: '0x027D50F36fe3b64630170B3ba82FC64BfC9bc088', + farmName: 'FAN-BNB', + tokenAddress: '0xFAc3A1ED2480Da8F5c34576C0Da13F245239717d', + quoteToken: bscTokens.wbnb, + tokenName: 'Fanadise', + projectSite: 'https://fanadise.com/', + }, + { + account: '0x73f9eb8eB7109b171396C8cbffcb29839c8b3064', + farmName: 'PKMON-BUSD', + tokenAddress: '0x609D183Fb91a0fce59550b62ab7d2c931b0Bb1BE', + quoteToken: bscTokens.busd, + tokenName: 'PolkaMonster', + projectSite: 'https://polkamonster.game/', + }, + { + account: '0x88Dba2cF8911A80cc50A1B392b5fF6b47B930330', + farmName: 'SFUND-BNB', + tokenAddress: '0x477bC8d23c634C154061869478bce96BE6045D12', + quoteToken: bscTokens.wbnb, + tokenName: 'Seedify', + projectSite: 'https://launchpad.seedify.fund/', + }, + { + account: '0xf1dD352EF3a94F60b3047B607C2Bd976401F538c', + farmName: 'GNT-BNB', + tokenAddress: '0xF750A26EB0aCf95556e8529E72eD530f3b60f348', + quoteToken: bscTokens.wbnb, + tokenName: 'GreenTrust', + projectSite: 'https://www.greentrusttoken.com/', + }, + { + account: '0x3992D7D9Ed721257d8bD7501d280b857eD7F9C24', + farmName: 'TT-BUSD', + tokenAddress: '0x990E7154bB999FAa9b2fa5Ed29E822703311eA85', + quoteToken: bscTokens.busd, + tokenName: 'ThunderCore', + projectSite: 'https://www.thundercore.com/', + }, + { + account: '0x2Ef317299888DD4a4F57FFf99FF2685D544fEAf1', + farmName: 'TT-BNB', + tokenAddress: '0x990E7154bB999FAa9b2fa5Ed29E822703311eA85', + quoteToken: bscTokens.wbnb, + tokenName: 'ThunderCore', + projectSite: 'https://www.thundercore.com/', + }, + { + account: '0xB9a32da7F33731FfDa8e7ecCB91325eee8A524AC', + farmName: 'SMG-BNB', + tokenAddress: '0x6bfd576220e8444CA4Cc5f89Efbd7f02a4C94C16', + quoteToken: bscTokens.wbnb, + tokenName: 'Smaugs NFT', + projectSite: 'https://smaugs.com', + }, + { + account: '0x5ed6B80F0e8b1c7fdB783202d4a926BbED2d49ee', + farmName: 'TENFI-BNB', + tokenAddress: '0xd15C444F1199Ae72795eba15E8C1db44E47abF62', + quoteToken: bscTokens.wbnb, + tokenName: 'TEN Finance', + projectSite: 'https://ten.finance/', + }, + { + account: '0x75015B56dA228A5367d313866f6520495344C65c', + farmName: 'BNX-BUSD', + tokenAddress: '0x8C851d1a123Ff703BD1f9dabe631b69902Df5f97', + quoteToken: bscTokens.busd, + tokenName: 'BinaryX', + projectSite: 'https://www.binaryx.pro/#/', + }, + { + account: '0xCbD932aC66f645a3764733aACD30Ce50e522Fac1', + farmName: 'DVI-BNB', + tokenAddress: '0x758FB037A375F17c7e195CC634D77dA4F554255B', + quoteToken: bscTokens.wbnb, + tokenName: 'Dvision', + projectSite: 'https://dvision.network/', + }, + { + account: '0xeA96c1970b9E3d4258620F68Af95ddDEB5fbD68F', + farmName: 'SALE-BNB', + tokenAddress: '0x97bb08ba41f033beaac315169fc566ac9e0daf52', + quoteToken: bscTokens.wbnb, + tokenName: 'DxSale Network', + projectSite: 'https://dxsale.app', + }, + { + account: '0xaDB2d11817Cd16595E4454aD03F95575c3B388f2', + farmName: 'MONI-BNB', + tokenAddress: '0x9573c88ae3e37508f87649f87c4dd5373c9f31e0', + quoteToken: bscTokens.wbnb, + tokenName: 'Monsta Infinite', + projectSite: 'https://monstainfinite.com/', + }, + { + account: '0xDa6e741A7f7d4d88d4210340069348704FDf21bf', + farmName: 'PROS-BNB', + tokenAddress: '0xed8c8aa8299c10f067496bb66f8cc7fb338a3405', + quoteToken: bscTokens.wbnb, + tokenName: 'Prosper', + projectSite: 'https://prosper.so/', + }, + { + account: '0xB651A851819638Cb120A46Db0E01Fa89006eE290', + farmName: 'CART-BNB', + tokenAddress: '0x5c8c8d560048f34e5f7f8ad71f2f81a89dbd273e', + quoteToken: bscTokens.wbnb, + tokenName: 'Cryptoart.ai', + projectSite: 'https://cryptoart.ai/', + }, + { + account: '0x73a4C2d21282dd9f9f2DF2aD3e06fd25aB487C9c', + farmName: 'XWIN-BNB', + tokenAddress: '0xd88ca08d8eec1E9E09562213Ae83A7853ebB5d28', + quoteToken: bscTokens.wbnb, + tokenName: 'xWIN Finance', + projectSite: 'https://xwin.finance/', + }, + { + account: '0x7Db4456a73a9C94a381d244E9dfC76E83C05913E', + farmName: 'SWAPP-BNB', + tokenAddress: '0x0efe961c733ff46ce34c56a73eba0c6a0e18e0f5', + quoteToken: bscTokens.wbnb, + tokenName: 'Swapp Protocol', + projectSite: 'https://swapp.ee', + }, + { + account: '0xB93A33f4cA46c1E1D65387313706cB8728B75703', + farmName: 'AIRT-BNB', + tokenAddress: '0x016cf83732f1468150d87dcc5bdf67730b3934d3', + quoteToken: bscTokens.wbnb, + tokenName: 'AirNFTs', + projectSite: 'https://airnfts.com/', + }, + { + account: '0x377056416332d017D2c2d140A097Ba8c2872bb60', + farmName: 'XMS-BNB', + tokenAddress: '0x7859b01bbf675d67da8cd128a50d155cd881b576', + quoteToken: bscTokens.wbnb, + tokenName: 'Mars Ecosystem', + projectSite: 'https://marsecosystem.com/', + }, + { + account: '0x6ff9B88eb94A976b0e1Db7713d8D765B8bE437a7', + farmName: 'LIGHT-BNB', + tokenAddress: '0x037838b556d9c9d654148a284682C55bB5f56eF4', + quoteToken: bscTokens.wbnb, + tokenName: 'Lightning', + projectSite: 'https://lightningprotocol.finance/', + }, + { + account: '0x235540Bd639308E51Efa89AbF2A9AF8bC1DEc877', + farmName: 'GENS-BUSD', + tokenAddress: '0x2CD14cbA3F26254beeD1d78158cd2B6F91809600', + quoteToken: bscTokens.busd, + tokenName: 'Genshiro', + projectSite: 'https://genshiro.equilibrium.io/en', + }, + { + account: '0xc55A7183F6D060271010A4441c106f6a81D46E34', + farmName: 'WSPP-BNB', + tokenAddress: '0x46d502fac9aea7c5bc7b13c8ec9d02378c33d36f', + quoteToken: bscTokens.wbnb, + tokenName: 'WolfSafePoorPeople', + projectSite: 'https://wolfsafepoorpeople.com', + }, + { + account: '0xC1d204015268CD808B765f024e04CE01d5Bff58D', + farmName: 'SHEESHA-BNB', + tokenAddress: '0x232fb065d9d24c34708eedbf03724f2e95abe768', + quoteToken: bscTokens.wbnb, + tokenName: 'Sheesha Finance', + projectSite: 'https://sheeshafinance.io', + }, + { + account: '0xb2bef43cb487bFc89770e2e88C23f6a2163133EE', + farmName: 'BSCS-BNB', + tokenAddress: '0xbcb24afb019be7e93ea9c43b7e22bb55d5b7f45d', + quoteToken: bscTokens.wbnb, + tokenName: 'BSCStation', + projectSite: 'https://bscstation.finance/', + }, + { + account: '0x47e947F01A17F8004D486fC7E37222B205a4c20b', + farmName: 'ARV-BNB', + tokenAddress: '0x6679eB24F59dFe111864AEc72B443d1Da666B360', + quoteToken: bscTokens.wbnb, + tokenName: 'Ariva', + projectSite: 'https://ariva.digital/', + }, + { + account: '0x8595c4Ad15D51c5Bf920c249869Ec5b3250c2D4d', + farmName: 'ULTI-BNB', + tokenAddress: '0x42BFE4A3E023f2C90aEBFfbd9B667599Fa38514F', + quoteToken: bscTokens.wbnb, + tokenName: 'ULTI Arena', + projectSite: 'https://ultiarena.com', + }, + { + account: '0x1723D77Afde343323b769271a83d5Aecada25e01', + farmName: 'ZOO-BUSD', + tokenAddress: '0x1D229B958D5DDFca92146585a8711aECbE56F095', + quoteToken: bscTokens.busd, + tokenName: 'ZOO Crypto World', + projectSite: 'https://zoogame.finance/', + }, + { + account: '0x8b519cD36b6a3179a4C560FcE987203E33df0366', + farmName: 'HERA-BNB', + tokenAddress: '0x49c7295ff86eabf5bf58c6ebc858db4805738c01', + quoteToken: bscTokens.wbnb, + tokenName: 'Hero Arena', + projectSite: 'https://heroarena.app/', + }, + { + account: '0xaCc34268f5D7Cb9B11BfB1ba4D8bD2bc2B49EE4E', + farmName: 'DPS-BNB', + tokenAddress: '0xf275e1AC303a4C9D987a2c48b8E555A77FeC3F1C', + quoteToken: bscTokens.wbnb, + tokenName: 'DEEPSPACE', + projectSite: 'https://deepspace.game', + }, + { + account: '0x050F559cD756cA09FC46988B6cf19ebF01256268', + farmName: 'BCOIN-BUSD', + tokenAddress: '0x00e1656e45f18ec6747F5a8496Fd39B50b38396D', + quoteToken: bscTokens.busd, + tokenName: 'Bomb Crypto', + projectSite: 'https://bombcrypto.io/', + }, + { + account: '0x6524b3B11979D5b5c354D5A804be9711d767f38F', + farmName: 'XEUS-BUSD', + tokenAddress: '0x4E141769366634D9c4e498257Fa7EC204d22b634', + quoteToken: bscTokens.busd, + tokenName: 'XEUS', + projectSite: 'https://xeus.finance/', + }, + { + account: '0x1Aa800bE7e9829DDF97C54EF750F5E42C2a6a884', + farmName: 'SHARPEI-BNB', + tokenAddress: '0xfE3AF7376e412a377358d5894C790bB3e00D0dc1', + quoteToken: bscTokens.wbnb, + tokenName: 'Shar Pei', + projectSite: 'https://sharpeitoken.io/', + }, + { + account: '0x2c32E56756964aCdB650521c1F10bdb939D5Ff7B', + farmName: 'PID-BUSD', + tokenAddress: '0x1215Ed20aa507578ca352E195016F289e7A17f3A', + quoteToken: bscTokens.busd, + tokenName: 'PIDAO', + projectSite: 'https://www.pidao.finance/', + }, + { + account: '0x4AD72A0841808b431525de29a7781d948675bAC7', + farmName: 'HTD-BUSD', + tokenAddress: '0x5E2689412Fae5c29BD575fbe1d5C1CD1e0622A8f', + quoteToken: bscTokens.busd, + tokenName: 'HeroesTD', + projectSite: 'https://heroestd.io/', + }, + { + account: '0xFfD8457466bAa1f11Bb585c7fD772Ad1A8b82b64', + farmName: 'GMEE-BNB', + tokenAddress: '0x84e9a6F9D240FdD33801f7135908BfA16866939A', + quoteToken: bscTokens.wbnb, + tokenName: 'GAMEE', + projectSite: 'https://token.gamee.com/', + }, + { + account: '0x820E53c3198dB5904938Bec31B3Ec3864a754c31', + farmName: 'ANTEX-BUSD', + tokenAddress: '0xCA1aCAB14e85F30996aC83c64fF93Ded7586977C', + quoteToken: bscTokens.busd, + tokenName: 'Antex', + projectSite: 'https://antex.org/', + }, + { + account: '0x5905A1F7BAf19844874B8B16E5FC4cde639b7a32', + farmName: 'SIP-BUSD', + tokenAddress: '0x9e5965d28E8D44CAE8F9b809396E0931F9Df71CA', + quoteToken: bscTokens.busd, + tokenName: 'Space Sip', + projectSite: 'https://sip.space/', + }, + { + account: '0x20C99830967a18563D2D3eD51094aDD9FBE06e2A', + farmName: 'SDAO-BNB', + tokenAddress: '0x90ed8f1dc86388f14b64ba8fb4bbd23099f18240', + quoteToken: bscTokens.wbnb, + tokenName: 'SingularityDAO', + projectSite: 'https://app.singularitydao.ai/', + }, + { + account: '0x304dDD664C961141B9C11F0ab597244306e021F4', + farmName: '8PAY-BUSD', + tokenAddress: '0xfeea0bdd3d07eb6fe305938878c0cadbfa169042', + quoteToken: bscTokens.busd, + tokenName: '8PAY', + projectSite: 'https://8pay.network/', + }, + { + account: '0xb8Ce421729232eCD5DFc7BD0adFe1f4DAd9D9CcE', + farmName: 'BATH-BUSD', + tokenAddress: '0x0bc89aa98Ad94E6798Ec822d0814d934cCD0c0cE', + quoteToken: bscTokens.busd, + tokenName: 'Battle Hero', + projectSite: 'https://battlehero.io/', + }, + { + account: '0x3591b656D753226dE239d2b9A48221daf0751Fca', + farmName: 'HE-BNB', + tokenAddress: '0x20d39a5130f799b95b55a930e5b7ebc589ea9ed8', + quoteToken: bscTokens.wbnb, + tokenName: 'Heroes & Empires', + projectSite: 'https://heroesempires.com/', + }, + { + account: '0xCbEd1a5c8847de8B284f7cf5cf752b3b2E3b5112', + farmName: 'AOG-BUSD', + tokenAddress: '0x40C8225329Bd3e28A043B029E0D07a5344d2C27C', + quoteToken: bscTokens.busd, + tokenName: 'AgeOfGods', + projectSite: 'https://ageofgods.net/', + }, + { + account: '0xCb70F0B3791D05D0D2Aec36805fd2411a89f3aa1', + farmName: 'PRL-BUSD', + tokenAddress: '0xd07e82440A395f3F3551b42dA9210CD1Ef4f8B24', + quoteToken: bscTokens.busd, + tokenName: 'The Parallel', + projectSite: 'https://theparallel.io/', + }, + { + account: '0xe60035673BAFDaD24C5B14E9556F5793dFFb3362', + farmName: 'LOA-BUSD', + tokenAddress: '0x94b69263fca20119ae817b6f783fc0f13b02ad50', + quoteToken: bscTokens.busd, + tokenName: 'League of Ancients', + projectSite: 'https://leagueofancients.com/', + }, + { + account: '0x05Adabb0f3bff63F5f7712f05F04F509494A18F3', + farmName: 'HOTCROSS-BNB', + tokenAddress: '0x4fa7163e153419e0e1064e418dd7a99314ed27b6', + quoteToken: bscTokens.wbnb, + tokenName: 'Hot Cross', + projectSite: 'https://hotcross.com/', + }, + { + account: '0x8e762609CEa5Ddd3234B9d41Cf8D0d8b4f2581a6', + farmName: 'TEM-BUSD', + tokenAddress: '0x19e6BfC1A6e4B042Fb20531244D47E252445df01', + quoteToken: bscTokens.busd, + tokenName: 'TemplarDAO', + projectSite: 'https://templar.finance/', + }, + { + account: '0xE9ab352015928CBE21771564E97bDAA3F5fbCBAC', + farmName: 'GRAV-BUSD', + tokenAddress: '0xa6168c7e5eb7c5c379f3a1d7cf1073e09b2f031e', + quoteToken: bscTokens.busd, + tokenName: 'Graviton Zero', + projectSite: 'https://gravitonzero.com/', + }, + { + account: '0x5Be8ed8EbCF5215A45E84B864526EfdF6F584152', + farmName: 'BABY-BNB', + tokenAddress: '0x53e562b9b7e5e94b81f10e96ee70ad06df3d2657', + quoteToken: bscTokens.wbnb, + tokenName: 'BabySwap', + projectSite: 'https://home.babyswap.finance/', + }, + { + account: '0x73e60b46908319B17f1De07C5d38437BFf684E50', + farmName: 'GEAR-BNB', + tokenAddress: '0xb4404DaB7C0eC48b428Cf37DeC7fb628bcC41B36', + quoteToken: bscTokens.wbnb, + tokenName: 'MetaGear', + projectSite: 'https://metagear.game/', + }, + { + account: '0xF113b815e24Cc866137c4933b39fe2878ED1F2d2', + farmName: 'RDR-BUSD', + tokenAddress: '0x92da433da84d58dfe2aade1943349e491cbd6820', + quoteToken: bscTokens.busd, + tokenName: 'Rise of Defenders', + projectSite: 'https://risedefenders.io/', + }, + { + account: '0x38408A0D905930f44fe6C53321684824b22c30c5', + farmName: 'FIGHT-BUSD', + tokenAddress: '0x4f39c3319188A723003670c3F9B9e7EF991E52F3', + quoteToken: bscTokens.busd, + tokenName: 'Crypto Fight Club', + projectSite: 'https://www.cryptofightclub.io/', + }, + { + account: '0xadF88A1eDC8F15CeA27F2674ED2BA1382F46A8A5', + farmName: 'DOME-BNB', + tokenAddress: '0x475bfaa1848591ae0e6ab69600f48d828f61a80e', + quoteToken: bscTokens.wbnb, + tokenName: 'Everdome', + projectSite: 'https://everdome.io/', + }, + { + account: '0xdE78F42bff7EDF1e70450e7BCFd8aBCF94e3a65e', + farmName: 'TINC-BNB', + tokenAddress: '0x05ad6e30a855be07afa57e08a4f30d00810a402e', + quoteToken: bscTokens.wbnb, + tokenName: 'Tiny World', + projectSite: 'https://tinyworlds.io/', + }, + { + account: '0x71F36803139caC2796Db65F373Fb7f3ee0bf3bF9', + farmName: 'BLP-BUSD', + tokenAddress: '0xfe1d7f7a8f0bda6e415593a2e4f82c64b446d404', + quoteToken: bscTokens.busd, + tokenName: 'Bull Perks', + projectSite: 'https://bullperks.com/', + }, + { + account: '0x5735BB4e439474828235a5F4048eDf0240dcA7F2', + farmName: 'YEL-BNB', + tokenAddress: '0xd3b71117e6c1558c1553305b44988cd944e97300', + quoteToken: bscTokens.wbnb, + tokenName: 'YEL Token', + projectSite: 'https://yel.finance/', + }, + { + account: '0x638fBD99Fe8CC28535Fa05D3825a028c0a1E430d', + farmName: 'MNFT-BUSD', + tokenAddress: '0x36953b5ec00a13edceceb3af258d034913d2a79d', + quoteToken: bscTokens.busd, + tokenName: 'ManuFactory', + projectSite: 'https://manufactory.gg', + }, + { + account: '0x00b4565008cD3f71DECf5DCa5e8Ebfc859eED35B', + farmName: 'DFIAT-BUSD', + tokenAddress: '0xF64eD9Ad397A1Ae657F31131d4B189220A7f1cc7', + quoteToken: bscTokens.busd, + tokenName: 'DeFiato', + projectSite: 'https://defiato.com/', + }, + { + account: '0x7a837dE1Aa84E60273864025eaffecE8D9e51FFe', + farmName: 'HAPPY-BNB', + tokenAddress: '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', + quoteToken: bscTokens.wbnb, + tokenName: 'HappyFans', + projectSite: 'https://happyfans.club/', + }, + { + account: '0x0888406F1091D18e941F3Fe74ee0286963FFAc48', + farmName: 'WZRD-BUSD', + tokenAddress: '0xFa40d8FC324bcdD6Bbae0e086De886c571C225d4', + quoteToken: bscTokens.busd, + tokenName: 'Wizardia', + projectSite: 'https://wizardia.io/', + }, + { + account: '0x83e0dE1c6dD34e07D5b1BAF36b367e22C8b6fDdF', + farmName: 'XCN-BNB', + tokenAddress: '0x7324c7C0d95CEBC73eEa7E85CbAac0dBdf88a05b', + quoteToken: bscTokens.wbnb, + tokenName: 'Chain', + projectSite: 'https://chain.com/', + }, + { + account: '0x4D85770FD4d42060d3A8075eF781830954b5C93F', + farmName: 'eLunr-BUSD', + tokenAddress: '0x37807D4fbEB84124347B8899Dd99616090D3e304', + quoteToken: bscTokens.busd, + tokenName: 'LunarCrush', + projectSite: 'https://lunarcrush.com/', + }, + { + account: '0x4acD36243d2cdE7865CA13E827ede5fBFF1ADe3d', + farmName: 'ETM-BUSD', + tokenAddress: '0x75bDEd6BF44bb01527138673dCc064DBe3E7d96d', + quoteToken: bscTokens.busd, + tokenName: 'Etermon', + projectSite: 'https://etermon.io/', + }, + { + account: '0x3b8eA037356CfD867c2191FD11614FA97BAB2772', + farmName: 'NBT-USDT', + tokenAddress: '0x1D3437E570e93581Bd94b2fd8Fbf202d4a65654A', + quoteToken: bscTokens.usdt, + tokenName: 'NanoByte', + projectSite: 'https://www.nanobyte.finance/', + }, + { + account: '0xf2110Fb93F8Ed4528A5849C9fDEDC589349a07dc', + farmName: 'SB-USDT', + tokenAddress: '0xB7258450681f4aAd0ab24E336648d44A6696B30f', + quoteToken: bscTokens.usdt, + tokenName: 'DragonSB', + projectSite: 'https://dragonsb.finance/', + }, + { + account: '0x3846e7A1A5dEA3F43104ed89ff0E6FfD1Cc74b6E', + farmName: 'PEAK-BNB', + tokenAddress: '0x630d98424eFe0Ea27fB1b3Ab7741907DFFEaAd78', + quoteToken: bscTokens.wbnb, + tokenName: 'PEAKDEFI', + projectSite: 'https://peakdefi.com/', + }, + { + account: '0x6587515802FF7f9cD7442EAE8dfAE20f9d71306F', + farmName: 'SHELL-BUSD', + tokenAddress: '0x208cfEc94d2BA8B8537da7A9BB361c6baAD77272', + quoteToken: bscTokens.busd, + tokenName: 'SHELL', + projectSite: 'https://metaapesgame.com/', + }, + { + account: '0x1170852F4C69d458f6ef7375EF7fa7c74AdD3F04', + farmName: 'MHUNT-BNB', + tokenAddress: '0x2C717059b366714d267039aF8F59125CAdce6D8c', + quoteToken: bscTokens.wbnb, + tokenName: 'MHUNT', + projectSite: 'https://metashooter.gg/', + }, + { + account: '0x6a2d41c87c3F28C2C0b466424DE8e08FC2E23eDc', + farmName: 'AOG-CAKE', + tokenAddress: '0x40C8225329Bd3e28A043B029E0D07a5344d2C27C', + quoteToken: bscTokens.cake, + tokenName: 'AOG', + projectSite: 'https://ageofgods.net/', + }, + { + account: '0xe01935Ef7BEF076eE0257C4D5601940490a8d266', + farmName: 'XCAD-BUSD', + tokenAddress: '0x431e0cD023a32532BF3969CddFc002c00E98429d', + quoteToken: bscTokens.busd, + tokenName: 'XCAD', + projectSite: 'https://xcadnetwork.com/', + }, +].map((bidderConfig) => ({ + ...bidderConfig, + lpAddress: getLpAddress(bidderConfig.tokenAddress, bidderConfig.quoteToken), +})) const UNKNOWN_BIDDER: FarmAuctionBidderConfig = { account: '', tokenAddress: '', - quoteToken: tokens.wbnb, + quoteToken: bscTokens.wbnb, farmName: 'Unknown', tokenName: 'Unknown', } diff --git a/src/config/constants/farms.ts b/src/config/constants/farms.ts index d7dfa68dd..442ddfcd4 100644 --- a/src/config/constants/farms.ts +++ b/src/config/constants/farms.ts @@ -1,8 +1,10 @@ -import { serializeTokens } from './tokens' +import { serializeTokens } from 'utils/serializeTokens' +import { bscTokens } from './tokens' import { SerializedFarmConfig } from './types' -import { CHAIN_ID } from './networks' -const serializedTokens = serializeTokens() +const serializedTokens = serializeTokens(bscTokens) + +export const CAKE_BNB_LP_MAINNET = '0x0eD7e52944161450477ee417DE9Cd3a859b14fD0' const farms: SerializedFarmConfig[] = [ /** @@ -25,7 +27,7 @@ const farms: SerializedFarmConfig[] = [ lpSymbol: 'CAKE-BNB LP', lpAddresses: { 97: '0x3ed8936cAFDF85cfDBa29Fbe5940A5b0524824F4', - 56: '0x0eD7e52944161450477ee417DE9Cd3a859b14fD0', + 56: CAKE_BNB_LP_MAINNET, }, token: serializedTokens.cake, quoteToken: serializedTokens.wbnb, @@ -1214,6 +1216,6 @@ const farms: SerializedFarmConfig[] = [ token: serializedTokens.ada, quoteToken: serializedTokens.wbnb, }, -].filter((f) => !!f.lpAddresses[CHAIN_ID]) +] export default farms diff --git a/src/config/constants/ifo.ts b/src/config/constants/ifo.ts index e7a658b5b..7752a6663 100644 --- a/src/config/constants/ifo.ts +++ b/src/config/constants/ifo.ts @@ -1,9 +1,9 @@ import { Token, ChainId } from '@pancakeswap/sdk' -import tokens from './tokens' -import farms from './farms' +import { bscTokens } from './tokens' +import { CAKE_BNB_LP_MAINNET } from './farms' import { Ifo } from './types' -export const cakeBnbLpToken = new Token(ChainId.MAINNET, farms[1].lpAddresses[ChainId.MAINNET], 18, farms[1].lpSymbol) +export const cakeBnbLpToken = new Token(ChainId.BSC, CAKE_BNB_LP_MAINNET, 18, 'CAKE-BNB LP') const ifos: Ifo[] = [ { @@ -23,8 +23,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.8, }, - currency: tokens.cake, - token: tokens.trivia, + currency: bscTokens.cake, + token: bscTokens.trivia, releaseBlockNumber: 19273145, campaignId: '511200000', articleUrl: @@ -54,8 +54,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.8, }, - currency: tokens.cake, - token: tokens.duet, + currency: bscTokens.cake, + token: bscTokens.duet, releaseBlockNumber: null, campaignId: '511190000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmXwoYYd8rkahVbxiGKsTa4rYRRFWPxhRGAHy3hVwK3Q2z', @@ -83,8 +83,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.8, }, - currency: tokens.cake, - token: tokens.era, + currency: bscTokens.cake, + token: bscTokens.era, releaseBlockNumber: 15156634, campaignId: '511180000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmTfN1SKnFidF6XCDcpga7zAf69mFfhb26Zy9b85dYskxW', @@ -112,8 +112,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.7, }, - currency: tokens.cake, - token: tokens.froyo, + currency: bscTokens.cake, + token: bscTokens.froyo, releaseBlockNumber: 14297000, campaignId: '511170000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmRhc4oC73jk4zxU4YkP1kudKHeq6qamgYA1sWoh6XJnks', @@ -140,8 +140,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.7, }, - currency: tokens.cake, - token: tokens.dpt, + currency: bscTokens.cake, + token: bscTokens.dpt, releaseBlockNumber: 13491500, campaignId: '511160000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmQqpknHvuQwshVP259qFxfQsxiWbQ9SLMebohDeRwRzKg', @@ -165,8 +165,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.7, }, - currency: tokens.cake, - token: tokens.santos, + currency: bscTokens.cake, + token: bscTokens.santos, releaseBlockNumber: 13097777, campaignId: '511150000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmUqRxjwZCWeZWEdgV2vHJ6hex7jMW7i247NKFas73xc8j', @@ -190,8 +190,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.5, }, - currency: tokens.cake, - token: tokens.porto, + currency: bscTokens.cake, + token: bscTokens.porto, releaseBlockNumber: 12687500, campaignId: '511140000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmaakXYpydAwCgTuSPe3R2ZNraRtkCbK6iBRqBCCdzqKEG', @@ -215,8 +215,8 @@ const ifos: Ifo[] = [ cakeToBurn: '$0', distributionRatio: 0.5, }, - currency: tokens.cake, - token: tokens.dar, + currency: bscTokens.cake, + token: bscTokens.dar, releaseBlockNumber: 12335455, campaignId: '511130000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmeJenHcbY45eQxLRebzvpNk5qSCrj2wM1t4EAMHotFoJL', @@ -241,7 +241,7 @@ const ifos: Ifo[] = [ distributionRatio: 0.7, }, currency: cakeBnbLpToken, - token: tokens.dkt, + token: bscTokens.dkt, releaseBlockNumber: 12130750, campaignId: '511120000', articleUrl: 'https://pancakeswap.finance/voting/proposal/QmTRWdW9a65fAkyJy1wrAJRU548fNMAZhRUDrSxzMDLmwk', @@ -266,7 +266,7 @@ const ifos: Ifo[] = [ distributionRatio: 0.7, }, currency: cakeBnbLpToken, - token: tokens.kalm, + token: bscTokens.kalm, releaseBlockNumber: 7707736, campaignId: '511110000', articleUrl: 'https://pancakeswap.medium.com/kalmar-kalm-ifo-to-be-hosted-on-pancakeswap-4540059753e4', @@ -291,7 +291,7 @@ const ifos: Ifo[] = [ distributionRatio: 0.7, }, currency: cakeBnbLpToken, - token: tokens.hotcross, + token: bscTokens.hotcross, releaseBlockNumber: 7477900, campaignId: '511100000', articleUrl: 'https://pancakeswap.medium.com/hot-cross-hotcross-ifo-to-be-hosted-on-pancakeswap-10e70f1f6841', @@ -316,7 +316,7 @@ const ifos: Ifo[] = [ distributionRatio: 0.7, }, currency: cakeBnbLpToken, - token: tokens.hzn, + token: bscTokens.hzn, releaseBlockNumber: 6581111, campaignId: '511090000', articleUrl: 'https://pancakeswap.medium.com/horizon-protocol-hzn-ifo-to-be-hosted-on-pancakeswap-51f79601c9d8', @@ -335,7 +335,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.belt, + token: bscTokens.belt, releaseBlockNumber: 5493919, campaignId: '511080000', articleUrl: 'https://pancakeswap.medium.com/belt-fi-belt-ifo-to-be-hosted-on-pancakeswap-353585117e32', @@ -354,7 +354,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.watch, + token: bscTokens.watch, releaseBlockNumber: 5294924, campaignId: '511070000', articleUrl: 'https://pancakeswap.medium.com/yieldwatch-watch-ifo-to-be-hosted-on-pancakeswap-d24301f17241', @@ -373,7 +373,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.bry, + token: bscTokens.bry, releaseBlockNumber: 4750968, campaignId: '511060000', articleUrl: 'https://pancakeswap.medium.com/berry-bry-ifo-to-be-hosted-on-pancakeswap-b4f9095e9cdb', @@ -392,7 +392,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.wsote, + token: bscTokens.wsote, releaseBlockNumber: 4086064, campaignId: '511050000', articleUrl: 'https://pancakeswap.medium.com/soteria-sota-ifo-to-be-hosted-on-pancakeswap-64b727c272ae', @@ -411,7 +411,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.helmet, + token: bscTokens.helmet, releaseBlockNumber: 3771926, campaignId: '511040000', articleUrl: 'https://pancakeswap.medium.com/1-000-000-helmet-helmet-ifo-to-be-hosted-on-pancakeswap-3379a2a89a67', @@ -430,7 +430,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.ten, + token: bscTokens.ten, releaseBlockNumber: 3483883, campaignId: '511030000', articleUrl: 'https://pancakeswap.medium.com/tenet-ten-ifo-to-be-hosted-on-pancakeswap-b7e1eb4cb272', @@ -449,7 +449,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.ditto, + token: bscTokens.ditto, releaseBlockNumber: 3279767, campaignId: '511020000', articleUrl: 'https://pancakeswap.medium.com/ditto-money-ditto-ifo-to-be-hosted-on-pancakeswap-342da3059a66', @@ -468,7 +468,7 @@ const ifos: Ifo[] = [ distributionRatio: 1, }, currency: cakeBnbLpToken, - token: tokens.blink, + token: bscTokens.blink, releaseBlockNumber: 3279767, campaignId: '511010000', articleUrl: 'https://medium.com/pancakeswap/1-000-000-ifo-blink-joins-pancakeswap-15841800bdd8', diff --git a/src/config/constants/index.ts b/src/config/constants/index.ts index 3ad7397de..f2cfe30b3 100644 --- a/src/config/constants/index.ts +++ b/src/config/constants/index.ts @@ -1,18 +1,18 @@ // used to construct the list of all pairs we consider by default in the frontend import { ChainId, Token } from '@pancakeswap/sdk' -import { mainnetTokens, testnetTokens } from './tokens' +import { bscTokens, bscTestnetTokens } from './tokens' import { ChainTokenList } from './types' export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = { - [ChainId.MAINNET]: [mainnetTokens.wbnb, mainnetTokens.dai, mainnetTokens.busd, mainnetTokens.usdt], - [ChainId.TESTNET]: [testnetTokens.wbnb, testnetTokens.cake, testnetTokens.busd], + [ChainId.BSC]: [bscTokens.wbnb, bscTokens.dai, bscTokens.busd, bscTokens.usdt], + [ChainId.BSC_TESTNET]: [bscTestnetTokens.wbnb, bscTestnetTokens.cake, bscTestnetTokens.busd], } export const PINNED_PAIRS: { readonly [chainId in ChainId]?: [Token, Token][] } = { - [ChainId.MAINNET]: [ - [mainnetTokens.cake, mainnetTokens.wbnb], - [mainnetTokens.busd, mainnetTokens.usdt], - [mainnetTokens.dai, mainnetTokens.usdt], + [ChainId.BSC]: [ + [bscTokens.cake, bscTokens.wbnb], + [bscTokens.busd, bscTokens.usdt], + [bscTokens.dai, bscTokens.usdt], ], } @@ -49,5 +49,3 @@ export const PREDICTION_TOOLTIP_DISMISS_KEY = 'prediction-switcher-dismiss-toolt export const GELATO_NATIVE = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' export const EXCHANGE_DOCS_URLS = 'https://docs.pancakeswap.finance/products/pancakeswap-exchange' - -export const GALAXY_NFT_CAMPAIGN_ID = 'GCpp2UUxqQ' diff --git a/src/config/constants/pools.tsx b/src/config/constants/pools.tsx index 208a6832c..ddb916f41 100644 --- a/src/config/constants/pools.tsx +++ b/src/config/constants/pools.tsx @@ -1,11 +1,11 @@ import { BigNumber } from '@ethersproject/bignumber' import Trans from 'components/Trans' import { VaultKey } from 'state/types' -import { CHAIN_ID } from './networks' -import tokens, { serializeTokens } from './tokens' +import { serializeTokens } from 'utils/serializeTokens' +import { bscTokens } from './tokens' import { SerializedPoolConfig, PoolCategory } from './types' -const serializedTokens = serializeTokens() +const serializedTokens = serializeTokens(bscTokens) export const MAX_LOCK_DURATION = 31536000 export const UNLOCK_FREE_DURATION = 604800 @@ -20,7 +20,7 @@ export const vaultPoolConfig = { autoCompoundFrequency: 5000, gasLimit: 380000, tokenImage: { - primarySrc: `/images/tokens/${tokens.cake.address}.svg`, + primarySrc: `/images/tokens/${bscTokens.cake.address}.svg`, secondarySrc: '/images/tokens/autorenew.svg', }, }, @@ -30,7 +30,7 @@ export const vaultPoolConfig = { autoCompoundFrequency: 5000, gasLimit: 500000, tokenImage: { - primarySrc: `/images/tokens/${tokens.cake.address}.svg`, + primarySrc: `/images/tokens/${bscTokens.cake.address}.svg`, secondarySrc: '/images/tokens/autorenew.svg', }, }, @@ -40,7 +40,7 @@ export const vaultPoolConfig = { autoCompoundFrequency: 5000, gasLimit: 500000, tokenImage: { - primarySrc: `/images/tokens/${tokens.cake.address}.svg`, + primarySrc: `/images/tokens/${bscTokens.cake.address}.svg`, secondarySrc: '/images/tokens/autorenew.svg', }, }, @@ -50,7 +50,7 @@ export const vaultPoolConfig = { autoCompoundFrequency: 1, gasLimit: 500000, tokenImage: { - primarySrc: `/images/tokens/${tokens.cake.address}.svg`, + primarySrc: `/images/tokens/${bscTokens.cake.address}.svg`, secondarySrc: `/images/tokens/ifo-pool-icon.svg`, }, }, @@ -129,7 +129,7 @@ export const livePools: SerializedPoolConfig[] = [ tokenPerBlock: '2.2505', version: 3, }, -].filter((p) => !!p.contractAddress[CHAIN_ID]) +] // known finished pools const finishedPools = [ @@ -3253,8 +3253,6 @@ const finishedPools = [ enableEmergencyWithdraw: true, tokenPerBlock: '7.502', }, -] - .filter((p) => !!p.contractAddress[CHAIN_ID]) - .map((p) => ({ ...p, isFinished: true })) +].map((p) => ({ ...p, isFinished: true })) export default [...livePools, ...finishedPools] diff --git a/src/config/constants/priceHelperLps.ts b/src/config/constants/priceHelperLps.ts index 6726b0f2b..18071d194 100644 --- a/src/config/constants/priceHelperLps.ts +++ b/src/config/constants/priceHelperLps.ts @@ -1,4 +1,4 @@ -import tokens from './tokens' +import { bscTokens } from './tokens' import { SerializedFarmConfig } from './types' const priceHelperLps: SerializedFarmConfig[] = [ @@ -16,8 +16,8 @@ const priceHelperLps: SerializedFarmConfig[] = [ 97: '', 56: '0x3147F98B8f9C53Acdf8F16332eaD12B592a1a4ae', }, - token: tokens.ankr, - quoteToken: tokens.wbnb, + token: bscTokens.ankr, + quoteToken: bscTokens.wbnb, }, { pid: null, @@ -26,8 +26,8 @@ const priceHelperLps: SerializedFarmConfig[] = [ 97: '', 56: '0x4DcB7b3b0E8914DC0e6D366521604cD23E7991E1', }, - token: tokens.antex, - quoteToken: tokens.busd, + token: bscTokens.antex, + quoteToken: bscTokens.busd, }, ] diff --git a/src/config/constants/rpc.ts b/src/config/constants/rpc.ts new file mode 100644 index 000000000..dd03f98fd --- /dev/null +++ b/src/config/constants/rpc.ts @@ -0,0 +1,11 @@ +export const BSC_RPC_URLS = [ + 'https://bsc-dataseed1.ninicoin.io', + 'https://bsc-dataseed1.defibit.io', + 'https://bsc-dataseed.binance.org', +] + +export const BSC_TESTNET_RPC_URLS = [ + 'https://data-seed-prebsc-1-s1.binance.org:8545', + 'https://data-seed-prebsc-2-s1.binance.org:8545', + 'https://data-seed-prebsc-1-s3.binance.org:8545', +] diff --git a/src/config/constants/swapWarningTokens.ts b/src/config/constants/swapWarningTokens.ts index 078cfe715..db7ed85f2 100644 --- a/src/config/constants/swapWarningTokens.ts +++ b/src/config/constants/swapWarningTokens.ts @@ -1,9 +1,9 @@ import { Token } from '@pancakeswap/sdk' -import tokens from 'config/constants/tokens' -import warningTokens from 'config/constants/warningTokens' +import { bscTokens } from 'config/constants/tokens' +import { bscWarningTokens } from 'config/constants/warningTokens' -const { bondly, safemoon, itam, ccar, bttold } = tokens -const { pokemoney, free } = warningTokens +const { bondly, itam, ccar, bttold } = bscTokens +const { pokemoney, free, safemoon } = bscWarningTokens interface WarningTokenList { [key: string]: Token diff --git a/src/config/constants/tokens.ts b/src/config/constants/tokens.ts index 704bc1dc9..14f6c46c9 100644 --- a/src/config/constants/tokens.ts +++ b/src/config/constants/tokens.ts @@ -1,58 +1,130 @@ -import { ChainId, Token } from '@pancakeswap/sdk' -import { serializeToken } from 'state/user/hooks/helpers' -import { CHAIN_ID } from './networks' -import { SerializedToken } from './types' +import { ChainId, Token, WBNB } from '@pancakeswap/sdk' -const { MAINNET, TESTNET } = ChainId +const CAKE_MAINNET = new Token( + ChainId.BSC, + '0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82', + 18, + 'CAKE', + 'PancakeSwap Token', + 'https://pancakeswap.finance/', +) -interface TokenList { - [symbol: string]: Token +const CAKE_TESTNET = new Token( + ChainId.BSC_TESTNET, + '0xa35062141Fa33BCA92Ce69FeD37D0E8908868AAe', + 18, + 'CAKE', + 'PancakeSwap Token', + 'https://pancakeswap.finance/', +) + +const USDC_BSC = new Token( + ChainId.BSC, + '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', + 18, + 'USDC', + 'Binance-Peg USD Coin', + 'https://www.centre.io/usdc', +) + +const USDC_TESTNET = new Token( + ChainId.BSC_TESTNET, + '0x64544969ed7EBf5f083679233325356EbE738930', + 18, + 'USDC', + 'Binance-Peg USD Coin', + 'https://www.centre.io/usdc', +) + +export const USDC = { + [ChainId.BSC]: USDC_BSC, + [ChainId.BSC_TESTNET]: USDC_TESTNET, +} + +export const CAKE = { + [ChainId.BSC]: CAKE_MAINNET, + [ChainId.BSC_TESTNET]: CAKE_TESTNET, } -export const defineTokens = (t: T) => t +const BUSD_MAINNET = new Token( + ChainId.BSC, + '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', + 18, + 'BUSD', + 'Binance USD', + 'https://www.paxos.com/busd/', +) -export const mainnetTokens = defineTokens({ - wbnb: new Token( - MAINNET, +const BUSD_TESTNET = new Token( + ChainId.BSC_TESTNET, + '0xeD24FC36d5Ee211Ea25A80239Fb8C4Cfd80f12Ee', + 18, + 'BUSD', + 'Binance USD', + 'https://www.paxos.com/busd/', +) + +export const BUSD: Record = { + [ChainId.BSC]: BUSD_MAINNET, + [ChainId.BSC_TESTNET]: BUSD_TESTNET, +} + +export const bscTokens = { + wbnb: WBNB[ChainId.BSC], + // bnb here points to the wbnb contract. Wherever the currency BNB is required, conditional checks for the symbol 'BNB' can be used + bnb: new Token( + ChainId.BSC, '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 18, - 'WBNB', - 'Wrapped BNB', + 'BNB', + 'BNB', 'https://www.binance.com/', ), - // bnb here points to the wbnb contract. Wherever the currency BNB is required, conditional checks for the symbol 'BNB' can be used - bnb: new Token(MAINNET, '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', 18, 'BNB', 'BNB', 'https://www.binance.com/'), - cake: new Token( - MAINNET, - '0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82', + cake: CAKE_MAINNET, + gmi: new Token(ChainId.BSC, '0x93D8d25E3C9A847a5Da79F79ecaC89461FEcA846', 18, 'GMI', 'Gamifi', 'https://gamifi.gg/'), + tlos: new Token( + ChainId.BSC, + '0xb6C53431608E626AC81a9776ac3e999c5556717c', 18, - 'CAKE', - 'PancakeSwap Token', - 'https://pancakeswap.finance/', + 'TLOS', + 'Telos', + 'https://www.telos.net/', ), - gmi: new Token(MAINNET, '0x93D8d25E3C9A847a5Da79F79ecaC89461FEcA846', 18, 'GMI', 'Gamifi', 'https://gamifi.gg/'), - tlos: new Token(MAINNET, '0xb6C53431608E626AC81a9776ac3e999c5556717c', 18, 'TLOS', 'Telos', 'https://www.telos.net/'), beta: new Token( - MAINNET, + ChainId.BSC, '0xBe1a001FE942f96Eea22bA08783140B9Dcc09D28', 18, 'BETA', 'Beta Finance', 'https://betafinance.org', ), - nft: new Token(MAINNET, '0x1fC9004eC7E5722891f5f38baE7678efCB11d34D', 6, 'NFT', 'APENFT', 'https://apenft.org'), + nft: new Token(ChainId.BSC, '0x1fC9004eC7E5722891f5f38baE7678efCB11d34D', 6, 'NFT', 'APENFT', 'https://apenft.org'), stephero: new Token( - MAINNET, + ChainId.BSC, '0xE8176d414560cFE1Bf82Fd73B986823B89E4F545', 18, 'HERO', 'StepHero', 'https://stephero.io/', ), - pros: new Token(MAINNET, '0xEd8c8Aa8299C10f067496BB66f8cC7Fb338A3405', 18, 'PROS', 'Prosper', 'https://prosper.so/'), - qbt: new Token(MAINNET, '0x17B7163cf1Dbd286E262ddc68b553D899B93f526', 18, 'QBT', 'Qubit Token', 'https://qbt.fi/'), + pros: new Token( + ChainId.BSC, + '0xEd8c8Aa8299C10f067496BB66f8cC7Fb338A3405', + 18, + 'PROS', + 'Prosper', + 'https://prosper.so/', + ), + qbt: new Token( + ChainId.BSC, + '0x17B7163cf1Dbd286E262ddc68b553D899B93f526', + 18, + 'QBT', + 'Qubit Token', + 'https://qbt.fi/', + ), cvp: new Token( - MAINNET, + ChainId.BSC, '0x5Ec3AdBDae549Dce842e24480Eb2434769e22B2E', 18, 'CVP', @@ -60,23 +132,16 @@ export const mainnetTokens = defineTokens({ 'https://powerpool.finance/', ), bscdefi: new Token( - MAINNET, + ChainId.BSC, '0x40E46dE174dfB776BB89E04dF1C47d8a66855EB3', 18, 'BSCDEFI', - 'BSC Defi blue chips token', + 'ChainId.BSC Defi blue chips token', 'https://powerpool.finance/', ), - busd: new Token( - MAINNET, - '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', - 18, - 'BUSD', - 'Binance USD', - 'https://www.paxos.com/busd/', - ), + busd: BUSD_MAINNET, dai: new Token( - MAINNET, + ChainId.BSC, '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3', 18, 'DAI', @@ -84,7 +149,7 @@ export const mainnetTokens = defineTokens({ 'https://www.makerdao.com/', ), usdt: new Token( - MAINNET, + ChainId.BSC, '0x55d398326f99059fF775485246999027B3197955', 18, 'USDT', @@ -92,7 +157,7 @@ export const mainnetTokens = defineTokens({ 'https://tether.to/', ), btcb: new Token( - MAINNET, + ChainId.BSC, '0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c', 18, 'BTCB', @@ -100,7 +165,7 @@ export const mainnetTokens = defineTokens({ 'https://bitcoin.org/', ), ust: new Token( - MAINNET, + ChainId.BSC, '0x23396cF899Ca06c4472205fC903bDB4de249D6fC', 18, 'UST', @@ -108,7 +173,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), eth: new Token( - MAINNET, + ChainId.BSC, '0x2170Ed0880ac9A755fd29B2688956BD959F933F8', 18, 'ETH', @@ -116,7 +181,7 @@ export const mainnetTokens = defineTokens({ 'https://ethereum.org/en/', ), usdc: new Token( - MAINNET, + ChainId.BSC, '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', 18, 'USDC', @@ -124,7 +189,7 @@ export const mainnetTokens = defineTokens({ 'https://www.centre.io/usdc', ), kalm: new Token( - MAINNET, + ChainId.BSC, '0x4BA0057f784858a48fe351445C672FF2a3d43515', 18, 'KALM', @@ -132,7 +197,7 @@ export const mainnetTokens = defineTokens({ 'https://kalmar.io/', ), dkt: new Token( - MAINNET, + ChainId.BSC, '0x7Ceb519718A80Dd78a8545AD8e7f401dE4f2faA7', 18, 'DKT', @@ -140,7 +205,7 @@ export const mainnetTokens = defineTokens({ 'https://duelistking.com/', ), hotcross: new Token( - MAINNET, + ChainId.BSC, '0x4FA7163E153419E0E1064e418dd7A99314Ed27b6', 18, 'HOTCROSS', @@ -148,7 +213,7 @@ export const mainnetTokens = defineTokens({ 'https://www.hotcross.com/', ), belt: new Token( - MAINNET, + ChainId.BSC, '0xE0e514c71282b6f4e823703a39374Cf58dc3eA4f', 18, 'BELT', @@ -156,7 +221,7 @@ export const mainnetTokens = defineTokens({ 'https://beta.belt.fi/', ), watch: new Token( - MAINNET, + ChainId.BSC, '0x7A9f28EB62C791422Aa23CeAE1dA9C847cBeC9b0', 18, 'WATCH', @@ -164,7 +229,7 @@ export const mainnetTokens = defineTokens({ 'https://yieldwatch.net/', ), bry: new Token( - MAINNET, + ChainId.BSC, '0xf859Bf77cBe8699013d6Dbc7C2b926Aaf307F830', 18, 'BRY', @@ -172,7 +237,7 @@ export const mainnetTokens = defineTokens({ 'https://berrydata.co/', ), wsote: new Token( - MAINNET, + ChainId.BSC, '0x541E619858737031A1244A5d0Cd47E5ef480342c', 18, 'wSOTE', @@ -180,7 +245,7 @@ export const mainnetTokens = defineTokens({ 'https://soteria.finance/', ), helmet: new Token( - MAINNET, + ChainId.BSC, '0x948d2a81086A075b3130BAc19e4c6DEe1D2E3fE8', 18, 'Helmet', @@ -188,7 +253,7 @@ export const mainnetTokens = defineTokens({ 'https://www.helmet.insure/', ), ten: new Token( - MAINNET, + ChainId.BSC, '0xdFF8cb622790b7F92686c722b02CaB55592f152C', 18, 'TEN', @@ -196,7 +261,7 @@ export const mainnetTokens = defineTokens({ 'https://www.tenet.farm/', ), ditto: new Token( - MAINNET, + ChainId.BSC, '0x233d91A0713155003fc4DcE0AFa871b508B3B715', 9, 'DITTO', @@ -204,7 +269,7 @@ export const mainnetTokens = defineTokens({ 'https://ditto.money/', ), blink: new Token( - MAINNET, + ChainId.BSC, '0x63870A18B6e42b01Ef1Ad8A2302ef50B7132054F', 6, 'BLINK', @@ -212,7 +277,7 @@ export const mainnetTokens = defineTokens({ 'https://blink.wink.org', ), syrup: new Token( - MAINNET, + ChainId.BSC, '0x009cF7bC57584b7998236eff51b98A168DceA9B0', 18, 'SYRUP', @@ -220,7 +285,7 @@ export const mainnetTokens = defineTokens({ 'https://pancakeswap.finance/', ), pha: new Token( - MAINNET, + ChainId.BSC, '0x0112e557d400474717056C4e6D40eDD846F38351', 18, 'PHA', @@ -228,7 +293,7 @@ export const mainnetTokens = defineTokens({ 'https://phala.network', ), babycake: new Token( - MAINNET, + ChainId.BSC, '0xdB8D30b74bf098aF214e862C90E647bbB1fcC58c', 18, 'BABYCAKE', @@ -236,7 +301,7 @@ export const mainnetTokens = defineTokens({ 'https://babycake.app/', ), bmon: new Token( - MAINNET, + ChainId.BSC, '0x08ba0619b1e7A582E0BCe5BBE9843322C954C340', 18, 'BMON', @@ -244,7 +309,7 @@ export const mainnetTokens = defineTokens({ 'https://binamon.org/', ), hero: new Token( - MAINNET, + ChainId.BSC, '0xD40bEDb44C081D2935eebA6eF5a3c8A31A1bBE13', 18, 'HERO', @@ -252,7 +317,7 @@ export const mainnetTokens = defineTokens({ 'https://metahero.io/', ), wsg: new Token( - MAINNET, + ChainId.BSC, '0xA58950F05FeA2277d2608748412bf9F802eA4901', 18, 'WSG', @@ -260,7 +325,7 @@ export const mainnetTokens = defineTokens({ 'https://wsg.gg/', ), mcrn: new Token( - MAINNET, + ChainId.BSC, '0xacb2d47827C9813AE26De80965845D80935afd0B', 18, 'MCRN', @@ -268,7 +333,7 @@ export const mainnetTokens = defineTokens({ 'https://www.macaronswap.finance/', ), revv: new Token( - MAINNET, + ChainId.BSC, '0x833F307aC507D47309fD8CDD1F835BeF8D702a93', 18, 'REVV', @@ -276,7 +341,7 @@ export const mainnetTokens = defineTokens({ 'https://revvmotorsport.com/', ), skill: new Token( - MAINNET, + ChainId.BSC, '0x154A9F9cbd3449AD22FDaE23044319D6eF2a1Fab', 18, 'SKILL', @@ -284,7 +349,7 @@ export const mainnetTokens = defineTokens({ 'https://www.cryptoblades.io/', ), if: new Token( - MAINNET, + ChainId.BSC, '0xB0e1fc65C1a741b4662B813eB787d369b8614Af1', 18, 'IF', @@ -292,7 +357,7 @@ export const mainnetTokens = defineTokens({ 'https://impossible.finance/', ), sps: new Token( - MAINNET, + ChainId.BSC, '0x1633b7157e7638C4d6593436111Bf125Ee74703F', 18, 'SPS', @@ -300,7 +365,7 @@ export const mainnetTokens = defineTokens({ 'https://splinterlands.com', ), chess: new Token( - MAINNET, + ChainId.BSC, '0x20de22029ab63cf9A7Cf5fEB2b737Ca1eE4c82A6', 18, 'CHESS', @@ -308,7 +373,7 @@ export const mainnetTokens = defineTokens({ 'https://tranchess.com/', ), titan: new Token( - MAINNET, + ChainId.BSC, '0xe898EDc43920F357A93083F1d4460437dE6dAeC2', 18, 'TITAN', @@ -316,16 +381,23 @@ export const mainnetTokens = defineTokens({ 'https://titanswap.org', ), harmony: new Token( - MAINNET, + ChainId.BSC, '0x03fF0ff224f904be3118461335064bB48Df47938', 18, 'ONE', 'Harmony ONE Token', 'https://www.harmony.one/', ), - mask: new Token(MAINNET, '0x2eD9a5C8C13b93955103B9a7C167B67Ef4d568a3', 18, 'MASK', 'Mask Token', 'https://mask.io/'), + mask: new Token( + ChainId.BSC, + '0x2eD9a5C8C13b93955103B9a7C167B67Ef4d568a3', + 18, + 'MASK', + 'Mask Token', + 'https://mask.io/', + ), dvi: new Token( - MAINNET, + ChainId.BSC, '0x758FB037A375F17c7e195CC634D77dA4F554255B', 18, 'DVI', @@ -333,7 +405,7 @@ export const mainnetTokens = defineTokens({ 'https://dvision.network/', ), adx: new Token( - MAINNET, + ChainId.BSC, '0x6bfF4Fb161347ad7de4A625AE5aa3A1CA7077819', 18, 'ADX', @@ -341,7 +413,7 @@ export const mainnetTokens = defineTokens({ 'https://www.adex.network', ), bscpad: new Token( - MAINNET, + ChainId.BSC, '0x5A3010d4d8D3B5fB49f8B6E57FB9E48063f16700', 18, 'BSCPAD', @@ -349,7 +421,7 @@ export const mainnetTokens = defineTokens({ 'https://bscpad.com/', ), rabbit: new Token( - MAINNET, + ChainId.BSC, '0x95a1199EBA84ac5f19546519e287d43D2F0E1b41', 18, 'RABBIT', @@ -357,16 +429,23 @@ export const mainnetTokens = defineTokens({ 'https://rabbitfinance.io/earn', ), form: new Token( - MAINNET, + ChainId.BSC, '0x25A528af62e56512A19ce8c3cAB427807c28CC19', 18, 'FORM', 'Formation Token', 'https://formation.fi/', ), - txl: new Token(MAINNET, '0x1FFD0b47127fdd4097E54521C9E2c7f0D66AafC5', 18, 'TXL', 'Tixl Token', 'https://tixl.org/'), + txl: new Token( + ChainId.BSC, + '0x1FFD0b47127fdd4097E54521C9E2c7f0D66AafC5', + 18, + 'TXL', + 'Tixl Token', + 'https://tixl.org/', + ), orbs: new Token( - MAINNET, + ChainId.BSC, '0xeBd49b26169e1b52c04cFd19FCf289405dF55F80', 18, 'ORBS', @@ -374,7 +453,7 @@ export const mainnetTokens = defineTokens({ 'https://www.orbs.com/', ), cos: new Token( - MAINNET, + ChainId.BSC, '0x96Dd399F9c3AFda1F194182F71600F1B65946501', 18, 'COS', @@ -382,7 +461,7 @@ export const mainnetTokens = defineTokens({ 'https://www.contentos.io/', ), bunny: new Token( - MAINNET, + ChainId.BSC, '0xC9849E6fdB743d08fAeE3E34dd2D1bc69EA11a51', 18, 'BUNNY', @@ -390,7 +469,7 @@ export const mainnetTokens = defineTokens({ 'https://pancakebunny.finance/', ), alice: new Token( - MAINNET, + ChainId.BSC, '0xAC51066d7bEC65Dc4589368da368b212745d63E8', 6, 'ALICE', @@ -398,7 +477,7 @@ export const mainnetTokens = defineTokens({ 'https://www.myneighboralice.com/', ), for: new Token( - MAINNET, + ChainId.BSC, '0x658A109C5900BC6d2357c87549B651670E5b0539', 18, 'FOR', @@ -406,7 +485,7 @@ export const mainnetTokens = defineTokens({ 'https://www.for.tube/home', ), bux: new Token( - MAINNET, + ChainId.BSC, '0x211FfbE424b90e25a15531ca322adF1559779E45', 18, 'BUX', @@ -414,7 +493,7 @@ export const mainnetTokens = defineTokens({ 'https://getbux.com/bux-crypto/', ), nuls: new Token( - MAINNET, + ChainId.BSC, '0x8CD6e29d3686d24d3C2018CEe54621eA0f89313B', 8, 'NULS', @@ -422,7 +501,7 @@ export const mainnetTokens = defineTokens({ 'https://www.nuls.io/', ), ramp: new Token( - MAINNET, + ChainId.BSC, '0x8519EA49c997f50cefFa444d240fB655e89248Aa', 18, 'RAMP', @@ -430,7 +509,7 @@ export const mainnetTokens = defineTokens({ 'https://rampdefi.com/', ), bfi: new Token( - MAINNET, + ChainId.BSC, '0x81859801b01764D4f0Fa5E64729f5a6C3b91435b', 18, 'BFI', @@ -438,7 +517,7 @@ export const mainnetTokens = defineTokens({ 'https://bearn.fi/', ), dexe: new Token( - MAINNET, + ChainId.BSC, '0x039cB485212f996A9DBb85A9a75d898F94d38dA6', 18, 'DEXE', @@ -446,7 +525,7 @@ export const mainnetTokens = defineTokens({ 'https://dexe.network/', ), bel: new Token( - MAINNET, + ChainId.BSC, '0x8443f091997f06a61670B735ED92734F5628692F', 18, 'BEL', @@ -454,7 +533,7 @@ export const mainnetTokens = defineTokens({ 'https://bella.fi/', ), tpt: new Token( - MAINNET, + ChainId.BSC, '0xECa41281c24451168a37211F0bc2b8645AF45092', 4, 'TPT', @@ -462,7 +541,7 @@ export const mainnetTokens = defineTokens({ 'https://www.tokenpocket.pro/', ), xmark: new Token( - MAINNET, + ChainId.BSC, '0x26A5dFab467d4f58fB266648CAe769503CEC9580', 9, 'xMARK', @@ -470,7 +549,7 @@ export const mainnetTokens = defineTokens({ 'https://benchmarkprotocol.finance/', ), bmxx: new Token( - MAINNET, + ChainId.BSC, '0x4131b87F74415190425ccD873048C708F8005823', 18, 'bMXX', @@ -478,7 +557,7 @@ export const mainnetTokens = defineTokens({ 'https://multiplier.finance/', ), iotx: new Token( - MAINNET, + ChainId.BSC, '0x9678E42ceBEb63F23197D726B29b1CB20d0064E5', 18, 'IOTX', @@ -486,7 +565,7 @@ export const mainnetTokens = defineTokens({ 'https://iotex.io/', ), bor: new Token( - MAINNET, + ChainId.BSC, '0x92D7756c60dcfD4c689290E8A9F4d263b3b32241', 18, 'BOR', @@ -494,7 +573,7 @@ export const mainnetTokens = defineTokens({ 'https://www.boringdao.com/', ), bopen: new Token( - MAINNET, + ChainId.BSC, '0xF35262a9d427F96d2437379eF090db986eaE5d42', 18, 'bOPEN', @@ -502,7 +581,7 @@ export const mainnetTokens = defineTokens({ 'https://opendao.io/', ), dodo: new Token( - MAINNET, + ChainId.BSC, '0x67ee3Cb086F8a16f34beE3ca72FAD36F7Db929e2', 18, 'DODO', @@ -510,7 +589,7 @@ export const mainnetTokens = defineTokens({ 'https://dodoex.io/', ), swingby: new Token( - MAINNET, + ChainId.BSC, '0x71DE20e0C4616E7fcBfDD3f875d568492cBE4739', 18, 'SWINGBY', @@ -518,7 +597,7 @@ export const mainnetTokens = defineTokens({ 'https://swingby.network/', ), zee: new Token( - MAINNET, + ChainId.BSC, '0x44754455564474A89358B2C2265883DF993b12F0', 18, 'ZEE', @@ -526,7 +605,7 @@ export const mainnetTokens = defineTokens({ 'https://zeroswap.io/', ), swgb: new Token( - MAINNET, + ChainId.BSC, '0xE40255C5d7fa7ceEc5120408C78C787CECB4cfdb', 18, 'SWGb', @@ -534,7 +613,7 @@ export const mainnetTokens = defineTokens({ 'https://swirgepay.com/', ), swg: new Token( - MAINNET, + ChainId.BSC, '0xe792f64C582698b8572AAF765bDC426AC3aEfb6B', 18, 'SWG', @@ -542,7 +621,7 @@ export const mainnetTokens = defineTokens({ 'https://swirgepay.com/', ), sfp: new Token( - MAINNET, + ChainId.BSC, '0xD41FDb03Ba84762dD66a0af1a6C8540FF1ba5dfb', 18, 'SFP', @@ -550,7 +629,7 @@ export const mainnetTokens = defineTokens({ 'https://www.safepal.io/', ), lina: new Token( - MAINNET, + ChainId.BSC, '0x762539b45A1dCcE3D36d080F74d1AED37844b878', 18, 'LINA', @@ -558,7 +637,7 @@ export const mainnetTokens = defineTokens({ 'https://linear.finance/', ), lit: new Token( - MAINNET, + ChainId.BSC, '0xb59490aB09A0f526Cc7305822aC65f2Ab12f9723', 18, 'LIT', @@ -566,7 +645,7 @@ export const mainnetTokens = defineTokens({ 'https://www.litentry.com/', ), hget: new Token( - MAINNET, + ChainId.BSC, '0xC7d8D35EBA58a0935ff2D5a33Df105DD9f071731', 6, 'HGET', @@ -574,7 +653,7 @@ export const mainnetTokens = defineTokens({ 'https://www.hedget.com/', ), bdo: new Token( - MAINNET, + ChainId.BSC, '0x190b589cf9Fb8DDEabBFeae36a813FFb2A702454', 18, 'BDO', @@ -582,7 +661,7 @@ export const mainnetTokens = defineTokens({ 'https://bdollar.fi/', ), egld: new Token( - MAINNET, + ChainId.BSC, '0xbF7c81FFF98BbE61B40Ed186e4AfD6DDd01337fe', 18, 'EGLD', @@ -590,7 +669,7 @@ export const mainnetTokens = defineTokens({ 'https://elrond.com/', ), front: new Token( - MAINNET, + ChainId.BSC, '0x928e55daB735aa8260AF3cEDadA18B5f70C72f1b', 18, 'FRONT', @@ -598,7 +677,7 @@ export const mainnetTokens = defineTokens({ 'https://frontier.xyz/', ), btcst: new Token( - MAINNET, + ChainId.BSC, '0x78650B139471520656b9E7aA7A5e9276814a38e9', 17, 'BTCST', @@ -606,7 +685,7 @@ export const mainnetTokens = defineTokens({ 'https://www.1-b.tc/', ), bscx: new Token( - MAINNET, + ChainId.BSC, '0x5Ac52EE5b2a633895292Ff6d8A89bB9190451587', 18, 'BSCX', @@ -614,7 +693,7 @@ export const mainnetTokens = defineTokens({ 'https://bscex.org/', ), balbt: new Token( - MAINNET, + ChainId.BSC, '0x72fAa679E1008Ad8382959FF48E392042A8b06f7', 18, 'bALBT', @@ -622,7 +701,7 @@ export const mainnetTokens = defineTokens({ 'https://allianceblock.io/', ), asr: new Token( - MAINNET, + ChainId.BSC, '0x80D5f92C2c8C682070C95495313dDB680B267320', 2, 'ASR', @@ -630,7 +709,7 @@ export const mainnetTokens = defineTokens({ 'https://www.chiliz.com', ), atm: new Token( - MAINNET, + ChainId.BSC, '0x25E9d05365c867E59C1904E7463Af9F312296f9E', 2, 'ATM', @@ -638,7 +717,7 @@ export const mainnetTokens = defineTokens({ 'https://www.chiliz.com', ), og: new Token( - MAINNET, + ChainId.BSC, '0xf05E45aD22150677a017Fbd94b84fBB63dc9b44c', 2, 'OG', @@ -646,7 +725,7 @@ export const mainnetTokens = defineTokens({ 'https://www.chiliz.com', ), reef: new Token( - MAINNET, + ChainId.BSC, '0xF21768cCBC73Ea5B6fd3C687208a7c2def2d966e', 18, 'REEF', @@ -654,7 +733,7 @@ export const mainnetTokens = defineTokens({ 'https://reef.finance/', ), juv: new Token( - MAINNET, + ChainId.BSC, '0xC40C9A843E1c6D01b7578284a9028854f6683b1B', 2, 'JUV', @@ -662,7 +741,7 @@ export const mainnetTokens = defineTokens({ 'https://www.chiliz.com', ), psg: new Token( - MAINNET, + ChainId.BSC, '0xBc5609612b7C44BEf426De600B5fd1379DB2EcF1', 2, 'PSG', @@ -670,7 +749,7 @@ export const mainnetTokens = defineTokens({ 'https://www.chiliz.com', ), vai: new Token( - MAINNET, + ChainId.BSC, '0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7', 18, 'VAI', @@ -678,7 +757,7 @@ export const mainnetTokens = defineTokens({ '0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7', ), unfi: new Token( - MAINNET, + ChainId.BSC, '0x728C5baC3C3e370E372Fc4671f9ef6916b814d8B', 18, 'UNFI', @@ -686,7 +765,7 @@ export const mainnetTokens = defineTokens({ 'https://unifiprotocol.com', ), twt: new Token( - MAINNET, + ChainId.BSC, '0x4B0F1812e5Df2A09796481Ff14017e6005508003', 18, 'TWT', @@ -694,7 +773,7 @@ export const mainnetTokens = defineTokens({ 'https://trustwallet.com/', ), hard: new Token( - MAINNET, + ChainId.BSC, '0xf79037F6f6bE66832DE4E7516be52826BC3cBcc4', 6, 'HARD', @@ -702,7 +781,7 @@ export const mainnetTokens = defineTokens({ 'https://hard.kava.io', ), broobee: new Token( - MAINNET, + ChainId.BSC, '0xE64F5Cb844946C1F102Bd25bBD87a5aB4aE89Fbe', 18, 'bROOBEE', @@ -710,7 +789,7 @@ export const mainnetTokens = defineTokens({ 'https://roobee.io/', ), stax: new Token( - MAINNET, + ChainId.BSC, '0x0Da6Ed8B13214Ff28e9Ca979Dd37439e8a88F6c4', 18, 'STAX', @@ -718,7 +797,7 @@ export const mainnetTokens = defineTokens({ 'https://stablexswap.com/', ), nar: new Token( - MAINNET, + ChainId.BSC, '0xA1303E6199b319a891b79685F0537D289af1FC83', 18, 'NAR', @@ -726,7 +805,7 @@ export const mainnetTokens = defineTokens({ 'https://narwhalswap.org/', ), nya: new Token( - MAINNET, + ChainId.BSC, '0xbFa0841F7a90c4CE6643f651756EE340991F99D5', 18, 'NYA', @@ -734,7 +813,7 @@ export const mainnetTokens = defineTokens({ 'https://nyanswop.org/', ), ctk: new Token( - MAINNET, + ChainId.BSC, '0xA8c2B8eec3d368C0253ad3dae65a5F2BBB89c929', 6, 'CTK', @@ -742,25 +821,39 @@ export const mainnetTokens = defineTokens({ 'https://www.certik.foundation/', ), inj: new Token( - MAINNET, + ChainId.BSC, '0xa2B726B1145A4773F68593CF171187d8EBe4d495', 18, 'INJ', 'Injective Protocol Token', 'https://injectiveprotocol.com/', ), - sxp: new Token(MAINNET, '0x47BEAd2563dCBf3bF2c9407fEa4dC236fAbA485A', 18, 'SXP', 'Swipe Token', 'https://swipe.io/'), + sxp: new Token( + ChainId.BSC, + '0x47BEAd2563dCBf3bF2c9407fEa4dC236fAbA485A', + 18, + 'SXP', + 'Swipe Token', + 'https://swipe.io/', + ), alpha: new Token( - MAINNET, + ChainId.BSC, '0xa1faa113cbE53436Df28FF0aEe54275c13B40975', 18, 'ALPHA', 'Alpha Finance Token', 'https://alphafinance.io/', ), - xvs: new Token(MAINNET, '0xcF6BB5389c92Bdda8a3747Ddb454cB7a64626C63', 18, 'XVS', 'Venus Token', 'https://venus.io/'), + xvs: new Token( + ChainId.BSC, + '0xcF6BB5389c92Bdda8a3747Ddb454cB7a64626C63', + 18, + 'XVS', + 'Venus Token', + 'https://venus.io/', + ), sushi: new Token( - MAINNET, + ChainId.BSC, '0x947950BcC74888a40Ffa2593C5798F11Fc9124C4', 18, 'SUSHI', @@ -768,7 +861,7 @@ export const mainnetTokens = defineTokens({ 'https://sushi.com/', ), comp: new Token( - MAINNET, + ChainId.BSC, '0x52CE071Bd9b1C4B00A0b92D298c512478CaD67e8', 18, 'COMP', @@ -776,7 +869,7 @@ export const mainnetTokens = defineTokens({ 'https://compound.finance/', ), bifi: new Token( - MAINNET, + ChainId.BSC, '0xCa3F508B8e4Dd382eE878A314789373D80A5190A', 18, 'BIFI', @@ -784,7 +877,7 @@ export const mainnetTokens = defineTokens({ 'https://beefy.finance/', ), dusk: new Token( - MAINNET, + ChainId.BSC, '0xB2BD0749DBE21f623d9BABa856D3B0f0e1BFEc9C', 18, 'DUSK', @@ -792,7 +885,7 @@ export const mainnetTokens = defineTokens({ 'https://dusk.network/', ), beth: new Token( - MAINNET, + ChainId.BSC, '0x250632378E573c6Be1AC2f97Fcdf00515d0Aa91B', 18, 'BETH', @@ -800,7 +893,7 @@ export const mainnetTokens = defineTokens({ 'https://ethereum.org/en/eth2/beacon-chain/', ), mamzn: new Token( - MAINNET, + ChainId.BSC, '0x3947B992DC0147D2D89dF0392213781b04B25075', 18, 'mAMZN', @@ -808,7 +901,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), mgoogl: new Token( - MAINNET, + ChainId.BSC, '0x62D71B23bF15218C7d2D7E48DBbD9e9c650B173f', 18, 'mGOOGL', @@ -816,7 +909,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), mnflx: new Token( - MAINNET, + ChainId.BSC, '0xa04F060077D90Fe2647B61e4dA4aD1F97d6649dc', 18, 'mNFLX', @@ -824,7 +917,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), mtsla: new Token( - MAINNET, + ChainId.BSC, '0xF215A127A196e3988C09d052e16BcFD365Cd7AA3', 18, 'mTSLA', @@ -832,7 +925,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), ltc: new Token( - MAINNET, + ChainId.BSC, '0x4338665CBB7B2485A8855A139b75D5e34AB0DB94', 18, 'LTC', @@ -840,7 +933,7 @@ export const mainnetTokens = defineTokens({ 'https://litecoin.org/', ), ada: new Token( - MAINNET, + ChainId.BSC, '0x3EE2200Efb3400fAbB9AacF31297cBdD1d435D47', 18, 'ADA', @@ -848,7 +941,7 @@ export const mainnetTokens = defineTokens({ 'https://www.cardano.org/', ), band: new Token( - MAINNET, + ChainId.BSC, '0xAD6cAEb32CD2c308980a548bD0Bc5AA4306c6c18', 18, 'BAND', @@ -856,7 +949,7 @@ export const mainnetTokens = defineTokens({ 'https://bandprotocol.com/', ), dot: new Token( - MAINNET, + ChainId.BSC, '0x7083609fCE4d1d8Dc0C979AAb8c869Ea2C873402', 18, 'DOT', @@ -864,7 +957,7 @@ export const mainnetTokens = defineTokens({ 'https://polkadot.network/', ), eos: new Token( - MAINNET, + ChainId.BSC, '0x56b6fB708fC5732DEC1Afc8D8556423A2EDcCbD6', 18, 'EOS', @@ -872,7 +965,7 @@ export const mainnetTokens = defineTokens({ 'https://eos.io/', ), link: new Token( - MAINNET, + ChainId.BSC, '0xF8A0BF9cF54Bb92F17374d9e9A321E6a111a51bD', 18, 'LINK', @@ -880,7 +973,7 @@ export const mainnetTokens = defineTokens({ 'https://chain.link/', ), xrp: new Token( - MAINNET, + ChainId.BSC, '0x1D2F0da169ceB9fC7B3144628dB156f3F6c60dBE', 18, 'XRP', @@ -888,7 +981,7 @@ export const mainnetTokens = defineTokens({ 'https://ripple.com/xrp/', ), atom: new Token( - MAINNET, + ChainId.BSC, '0x0Eb3a705fc54725037CC9e008bDede697f62F335', 18, 'ATOM', @@ -896,7 +989,7 @@ export const mainnetTokens = defineTokens({ 'https://cosmos.network/', ), yfii: new Token( - MAINNET, + ChainId.BSC, '0x7F70642d88cf1C4a3a7abb072B53B929b653edA5', 18, 'YFII', @@ -904,7 +997,7 @@ export const mainnetTokens = defineTokens({ 'https://dfi.money/#/', ), xtz: new Token( - MAINNET, + ChainId.BSC, '0x16939ef78684453bfDFb47825F8a5F714f12623a', 18, 'XTZ', @@ -912,7 +1005,7 @@ export const mainnetTokens = defineTokens({ 'https://www.tezos.com/', ), bch: new Token( - MAINNET, + ChainId.BSC, '0x8fF795a6F4D97E7887C79beA79aba5cc76444aDf', 18, 'BCH', @@ -920,7 +1013,7 @@ export const mainnetTokens = defineTokens({ 'https://bch.info/', ), yfi: new Token( - MAINNET, + ChainId.BSC, '0x88f1A5ae2A3BF98AEAF342D26B30a79438c9142e', 18, 'YFI', @@ -928,7 +1021,7 @@ export const mainnetTokens = defineTokens({ 'https://yearn.finance/', ), uni: new Token( - MAINNET, + ChainId.BSC, '0xBf5140A22578168FD562DCcF235E5D43A02ce9B1', 18, 'UNI', @@ -936,7 +1029,7 @@ export const mainnetTokens = defineTokens({ 'https://uniswap.org/', ), fil: new Token( - MAINNET, + ChainId.BSC, '0x0D8Ce2A99Bb6e3B7Db580eD848240e4a0F9aE153', 18, 'FIL', @@ -944,7 +1037,7 @@ export const mainnetTokens = defineTokens({ 'https://filecoin.io/', ), bake: new Token( - MAINNET, + ChainId.BSC, '0xE02dF9e3e622DeBdD69fb838bB799E3F168902c5', 18, 'BAKE', @@ -952,7 +1045,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bakeryswap.org/', ), burger: new Token( - MAINNET, + ChainId.BSC, '0xAe9269f27437f0fcBC232d39Ec814844a51d6b8f', 18, 'BURGER', @@ -960,7 +1053,7 @@ export const mainnetTokens = defineTokens({ 'https://burgerswap.org/', ), bdigg: new Token( - MAINNET, + ChainId.BSC, '0x5986D5c77c65e5801a5cAa4fAE80089f870A71dA', 18, 'bDIGG', @@ -968,7 +1061,7 @@ export const mainnetTokens = defineTokens({ 'https://badger.finance/', ), bbadger: new Token( - MAINNET, + ChainId.BSC, '0x1F7216fdB338247512Ec99715587bb97BBf96eae', 18, 'bBadger', @@ -976,7 +1069,7 @@ export const mainnetTokens = defineTokens({ 'https://badger.finance/', ), trade: new Token( - MAINNET, + ChainId.BSC, '0x7af173F350D916358AF3e218Bdf2178494Beb748', 18, 'TRADE', @@ -984,7 +1077,7 @@ export const mainnetTokens = defineTokens({ 'https://unitrade.app/', ), pnt: new Token( - MAINNET, + ChainId.BSC, '0xdaacB0Ab6Fb34d24E8a67BfA14BF4D95D4C7aF92', 18, 'PNT', @@ -992,7 +1085,7 @@ export const mainnetTokens = defineTokens({ 'https://ptokens.io/', ), mir: new Token( - MAINNET, + ChainId.BSC, '0x5B6DcF557E2aBE2323c48445E8CC948910d8c2c9', 18, 'MIR', @@ -1000,7 +1093,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), pbtc: new Token( - MAINNET, + ChainId.BSC, '0xeD28A457A5A76596ac48d87C0f577020F6Ea1c4C', 18, 'pBTC', @@ -1008,7 +1101,7 @@ export const mainnetTokens = defineTokens({ 'https://ptokens.io/', ), lto: new Token( - MAINNET, + ChainId.BSC, '0x857B222Fc79e1cBBf8Ca5f78CB133d1b7CF34BBd', 18, 'LTO', @@ -1016,7 +1109,7 @@ export const mainnetTokens = defineTokens({ 'https://ltonetwork.com/', ), pcws: new Token( - MAINNET, + ChainId.BSC, '0xbcf39F0EDDa668C58371E519AF37CA705f2bFcbd', 18, 'pCWS', @@ -1024,7 +1117,7 @@ export const mainnetTokens = defineTokens({ 'https://game.seascape.network/', ), zil: new Token( - MAINNET, + ChainId.BSC, '0xb86AbCb37C3A4B64f74f59301AFF131a1BEcC787', 12, 'ZIL', @@ -1032,7 +1125,7 @@ export const mainnetTokens = defineTokens({ 'https://www.zilliqa.com/', ), lien: new Token( - MAINNET, + ChainId.BSC, '0x5d684ADaf3FcFe9CFb5ceDe3abf02F0Cdd1012E3', 8, 'LIEN', @@ -1040,7 +1133,7 @@ export const mainnetTokens = defineTokens({ 'https://lien.finance/', ), swth: new Token( - MAINNET, + ChainId.BSC, '0x250b211EE44459dAd5Cd3bCa803dD6a7EcB5d46C', 8, 'SWTH', @@ -1048,7 +1141,7 @@ export const mainnetTokens = defineTokens({ 'https://switcheo.network/', ), dft: new Token( - MAINNET, + ChainId.BSC, '0x42712dF5009c20fee340B245b510c0395896cF6e', 18, 'DFT', @@ -1056,7 +1149,7 @@ export const mainnetTokens = defineTokens({ 'https://www.dfuture.com/home', ), gum: new Token( - MAINNET, + ChainId.BSC, '0xc53708664b99DF348dd27C3Ac0759d2DA9c40462', 18, 'GUM', @@ -1064,7 +1157,7 @@ export const mainnetTokens = defineTokens({ 'https://gourmetgalaxy.io/', ), dego: new Token( - MAINNET, + ChainId.BSC, '0x3FdA9383A84C05eC8f7630Fe10AdF1fAC13241CC', 18, 'DEGO', @@ -1072,7 +1165,7 @@ export const mainnetTokens = defineTokens({ 'https://bsc.dego.finance/home', ), nrv: new Token( - MAINNET, + ChainId.BSC, '0x42F6f551ae042cBe50C739158b4f0CAC0Edb9096', 18, 'NRV', @@ -1080,17 +1173,24 @@ export const mainnetTokens = defineTokens({ 'https://nerve.fi/', ), easy: new Token( - MAINNET, + ChainId.BSC, '0x7C17c8bED8d14bAccE824D020f994F4880D6Ab3B', 18, 'EASY', 'EASY Token', 'https://easyfi.network/', ), - oddz: new Token(MAINNET, '0xCD40F2670CF58720b694968698A5514e924F742d', 18, 'ODDZ', 'Oddz Token', 'https://oddz.fi/'), - hoo: new Token(MAINNET, '0xE1d1F66215998786110Ba0102ef558b22224C016', 8, 'HOO', 'Hoo Token', 'https://hoo.com/'), + oddz: new Token( + ChainId.BSC, + '0xCD40F2670CF58720b694968698A5514e924F742d', + 18, + 'ODDZ', + 'Oddz Token', + 'https://oddz.fi/', + ), + hoo: new Token(ChainId.BSC, '0xE1d1F66215998786110Ba0102ef558b22224C016', 8, 'HOO', 'Hoo Token', 'https://hoo.com/'), apys: new Token( - MAINNET, + ChainId.BSC, '0x37dfACfaeDA801437Ff648A1559d73f4C40aAcb7', 18, 'APYS', @@ -1098,7 +1198,7 @@ export const mainnetTokens = defineTokens({ 'https://apyswap.com/', ), bondly: new Token( - MAINNET, + ChainId.BSC, '0x96058f8C3e16576D9BD68766f3836d9A33158f89', 18, 'BONDLY', @@ -1106,7 +1206,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bondly.finance/', ), tko: new Token( - MAINNET, + ChainId.BSC, '0x9f589e3eabe42ebC94A44727b3f3531C0c877809', 18, 'TKO', @@ -1114,7 +1214,7 @@ export const mainnetTokens = defineTokens({ 'https://www.tokocrypto.com/', ), itam: new Token( - MAINNET, + ChainId.BSC, '0x04C747b40Be4D535fC83D09939fb0f626F32800B', 18, 'ITAM', @@ -1122,7 +1222,7 @@ export const mainnetTokens = defineTokens({ 'https://itam.network/', ), arpa: new Token( - MAINNET, + ChainId.BSC, '0x6F769E65c14Ebd1f68817F5f1DcDb61Cfa2D6f7e', 18, 'ARPA', @@ -1130,7 +1230,7 @@ export const mainnetTokens = defineTokens({ 'https://arpachain.io/', ), eps: new Token( - MAINNET, + ChainId.BSC, '0xA7f552078dcC247C2684336020c03648500C6d9F', 18, 'EPS', @@ -1138,7 +1238,7 @@ export const mainnetTokens = defineTokens({ 'https://ellipsis.finance/', ), jgn: new Token( - MAINNET, + ChainId.BSC, '0xC13B7a43223BB9Bf4B69BD68Ab20ca1B79d81C75', 18, 'JGN', @@ -1146,7 +1246,7 @@ export const mainnetTokens = defineTokens({ 'https://jgndefi.com/', ), tlm: new Token( - MAINNET, + ChainId.BSC, '0x2222227E22102Fe3322098e4CBfE18cFebD57c95', 4, 'TLM', @@ -1154,7 +1254,7 @@ export const mainnetTokens = defineTokens({ 'https://alienworlds.io/', ), perl: new Token( - MAINNET, + ChainId.BSC, '0x0F9E4D49f25de22c2202aF916B681FBB3790497B', 18, 'PERL', @@ -1162,7 +1262,7 @@ export const mainnetTokens = defineTokens({ 'https://perlinx.finance/', ), alpa: new Token( - MAINNET, + ChainId.BSC, '0xc5E6689C9c8B02be7C49912Ef19e79cF24977f03', 18, 'ALPA', @@ -1170,7 +1270,7 @@ export const mainnetTokens = defineTokens({ 'https://bsc.alpaca.city/', ), hzn: new Token( - MAINNET, + ChainId.BSC, '0xC0eFf7749b125444953ef89682201Fb8c6A917CD', 18, 'HZN', @@ -1178,7 +1278,7 @@ export const mainnetTokens = defineTokens({ 'https://horizonprotocol.com/', ), suter: new Token( - MAINNET, + ChainId.BSC, '0x4CfbBdfBd5BF0814472fF35C72717Bd095ADa055', 18, 'SUTER', @@ -1186,7 +1286,7 @@ export const mainnetTokens = defineTokens({ 'https://shield.suterusu.io/', ), cgg: new Token( - MAINNET, + ChainId.BSC, '0x1613957159E9B0ac6c80e824F7Eea748a32a0AE2', 18, 'CGG', @@ -1194,7 +1294,7 @@ export const mainnetTokens = defineTokens({ 'https://chainguardians.io/', ), mix: new Token( - MAINNET, + ChainId.BSC, '0xB67754f5b4C704A24d2db68e661b2875a4dDD197', 18, 'MIX', @@ -1202,7 +1302,7 @@ export const mainnetTokens = defineTokens({ 'https://mixie.chainguardians.io/', ), hakka: new Token( - MAINNET, + ChainId.BSC, '0x1D1eb8E8293222e1a29d2C0E4cE6C0Acfd89AaaC', 18, 'HAKKA', @@ -1210,7 +1310,7 @@ export const mainnetTokens = defineTokens({ 'https://hakka.finance/', ), xed: new Token( - MAINNET, + ChainId.BSC, '0x5621b5A3f4a8008c4CCDd1b942B121c8B1944F1f', 18, 'XED', @@ -1218,7 +1318,7 @@ export const mainnetTokens = defineTokens({ 'https://www.exeedme.com/', ), τbtc: new Token( - MAINNET, + ChainId.BSC, '0x2cD1075682b0FCCaADd0Ca629e138E64015Ba11c', 9, 'τBTC', @@ -1226,7 +1326,7 @@ export const mainnetTokens = defineTokens({ 'https://www.btcst.finance/', ), alpaca: new Token( - MAINNET, + ChainId.BSC, '0x8F0528cE5eF7B51152A59745bEfDD91D97091d2F', 18, 'ALPACA', @@ -1234,7 +1334,7 @@ export const mainnetTokens = defineTokens({ 'https://www.alpacafinance.org/', ), dfd: new Token( - MAINNET, + ChainId.BSC, '0x9899a98b222fCb2f3dbee7dF45d943093a4ff9ff', 18, 'DFD', @@ -1242,7 +1342,7 @@ export const mainnetTokens = defineTokens({ 'https://dusd.finance/', ), lmt: new Token( - MAINNET, + ChainId.BSC, '0x9617857E191354dbEA0b714d78Bc59e57C411087', 18, 'LMT', @@ -1250,7 +1350,7 @@ export const mainnetTokens = defineTokens({ 'https://lympo.io/lmt/', ), bttold: new Token( - MAINNET, + ChainId.BSC, '0x8595F9dA7b868b1822194fAEd312235E43007b49', 18, 'BTTOLD', @@ -1258,7 +1358,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bittorrent.com/', ), trx: new Token( - MAINNET, + ChainId.BSC, '0x85EAC5Ac2F758618dFa09bDbe0cf174e7d574D5B', 18, 'TRX', @@ -1266,7 +1366,7 @@ export const mainnetTokens = defineTokens({ 'https://tron.network/', ), win: new Token( - MAINNET, + ChainId.BSC, '0xaeF0d72a118ce24feE3cD1d43d383897D05B4e99', 18, 'WIN', @@ -1274,7 +1374,7 @@ export const mainnetTokens = defineTokens({ 'https://winklink.org/', ), mcoin: new Token( - MAINNET, + ChainId.BSC, '0x49022089e78a8D46Ec87A3AF86a1Db6c189aFA6f', 18, 'MCOIN', @@ -1282,7 +1382,7 @@ export const mainnetTokens = defineTokens({ 'https://mirror.finance/', ), math: new Token( - MAINNET, + ChainId.BSC, '0xF218184Af829Cf2b0019F8E6F0b2423498a36983', 18, 'MATH', @@ -1290,7 +1390,7 @@ export const mainnetTokens = defineTokens({ 'https://mathwallet.org/', ), kun: new Token( - MAINNET, + ChainId.BSC, '0x1A2fb0Af670D0234c2857FaD35b789F8Cb725584', 18, 'KUN', @@ -1298,7 +1398,7 @@ export const mainnetTokens = defineTokens({ 'https://chemix.io/home', ), qsd: new Token( - MAINNET, + ChainId.BSC, '0x07AaA29E63FFEB2EBf59B33eE61437E1a91A3bb2', 18, 'QSD', @@ -1306,7 +1406,7 @@ export const mainnetTokens = defineTokens({ 'https://chemix.io/home', ), hyfi: new Token( - MAINNET, + ChainId.BSC, '0x9a319b959e33369C5eaA494a770117eE3e585318', 18, 'HYFI', @@ -1314,7 +1414,7 @@ export const mainnetTokens = defineTokens({ 'https://hyfi.pro/#/', ), oin: new Token( - MAINNET, + ChainId.BSC, '0x658E64FFcF40D240A43D52CA9342140316Ae44fA', 8, 'OIN', @@ -1322,7 +1422,7 @@ export const mainnetTokens = defineTokens({ 'https://oin.finance/', ), doge: new Token( - MAINNET, + ChainId.BSC, '0xbA2aE424d960c26247Dd6c32edC70B295c744C43', 8, 'DOGE', @@ -1330,7 +1430,7 @@ export const mainnetTokens = defineTokens({ 'https://dogecoin.com/', ), fine: new Token( - MAINNET, + ChainId.BSC, '0x4e6415a5727ea08aAE4580057187923aeC331227', 18, 'FINE', @@ -1338,7 +1438,7 @@ export const mainnetTokens = defineTokens({ 'https://refinable.com/', ), one: new Token( - MAINNET, + ChainId.BSC, '0x04BAf95Fd4C52fd09a56D840bAEe0AB8D7357bf0', 18, 'ONE', @@ -1346,7 +1446,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bigone.com/', ), pmon: new Token( - MAINNET, + ChainId.BSC, '0x1796ae0b0fa4862485106a0de9b654eFE301D0b2', 18, 'PMON', @@ -1354,7 +1454,7 @@ export const mainnetTokens = defineTokens({ 'https://polkamon.com/', ), τdoge: new Token( - MAINNET, + ChainId.BSC, '0xe550a593d09FBC8DCD557b5C88Cea6946A8b404A', 8, 'τDOGE', @@ -1362,7 +1462,7 @@ export const mainnetTokens = defineTokens({ 'https://www.btcst.finance/', ), btr: new Token( - MAINNET, + ChainId.BSC, '0x5a16E8cE8cA316407c6E6307095dc9540a8D62B3', 18, 'BTR', @@ -1370,7 +1470,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bitrue.com/', ), ubxt: new Token( - MAINNET, + ChainId.BSC, '0xBbEB90cFb6FAFa1F69AA130B7341089AbeEF5811', 18, 'UBXT', @@ -1378,7 +1478,7 @@ export const mainnetTokens = defineTokens({ 'https://upbots.com/', ), wmass: new Token( - MAINNET, + ChainId.BSC, '0x7e396BfC8a2f84748701167c2d622F041A1D7a17', 8, 'WMASS', @@ -1386,7 +1486,7 @@ export const mainnetTokens = defineTokens({ 'https://massnet.org/en/', ), rfox: new Token( - MAINNET, + ChainId.BSC, '0x0a3A21356793B49154Fd3BbE91CBc2A16c0457f5', 18, 'RFOX', @@ -1394,16 +1494,23 @@ export const mainnetTokens = defineTokens({ 'https://www.redfoxlabs.io/', ), xend: new Token( - MAINNET, + ChainId.BSC, '0x4a080377f83D669D7bB83B3184a8A5E61B500608', 18, 'XEND', 'XEND Token', 'https://xend.finance/', ), - cyc: new Token(MAINNET, '0x810EE35443639348aDbbC467b33310d2AB43c168', 18, 'CYC', 'CYC Token', 'https://cyclone.xyz/'), + cyc: new Token( + ChainId.BSC, + '0x810EE35443639348aDbbC467b33310d2AB43c168', + 18, + 'CYC', + 'CYC Token', + 'https://cyclone.xyz/', + ), chr: new Token( - MAINNET, + ChainId.BSC, '0xf9CeC8d50f6c8ad3Fb6dcCEC577e05aA32B224FE', 6, 'CHR', @@ -1411,7 +1518,7 @@ export const mainnetTokens = defineTokens({ 'https://chromia.com/', ), deri: new Token( - MAINNET, + ChainId.BSC, '0xe60eaf5A997DFAe83739e035b005A33AfdCc6df5', 18, 'DERI', @@ -1419,7 +1526,7 @@ export const mainnetTokens = defineTokens({ 'https://deri.finance/#/index', ), well: new Token( - MAINNET, + ChainId.BSC, '0xf07a32Eb035b786898c00bB1C64d8c6F8E7a46D5', 18, 'WELL', @@ -1427,7 +1534,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bitwellex.com/', ), wex: new Token( - MAINNET, + ChainId.BSC, '0xa9c41A46a6B3531d28d5c32F6633dd2fF05dFB90', 18, 'WEX', @@ -1435,7 +1542,7 @@ export const mainnetTokens = defineTokens({ 'https://wault.finance/', ), waultx: new Token( - MAINNET, + ChainId.BSC, '0xB64E638E60D154B43f660a6BF8fD8a3b249a6a21', 18, 'WAULTx', @@ -1443,7 +1550,7 @@ export const mainnetTokens = defineTokens({ 'https://wault.finance/', ), popen: new Token( - MAINNET, + ChainId.BSC, '0xaBaE871B7E3b67aEeC6B46AE9FE1A91660AadAC5', 18, 'pOPEN', @@ -1451,7 +1558,7 @@ export const mainnetTokens = defineTokens({ 'https://opendao.io/', ), ez: new Token( - MAINNET, + ChainId.BSC, '0x5512014efa6Cd57764Fa743756F7a6Ce3358cC83', 18, 'EZ', @@ -1459,7 +1566,7 @@ export const mainnetTokens = defineTokens({ 'https://easyfi.network/', ), vrt: new Token( - MAINNET, + ChainId.BSC, '0x5F84ce30DC3cF7909101C69086c50De191895883', 18, 'VRT', @@ -1467,7 +1574,7 @@ export const mainnetTokens = defineTokens({ 'https://venus.io/', ), tusd: new Token( - MAINNET, + ChainId.BSC, '0x14016E85a25aeb13065688cAFB43044C2ef86784', 18, 'TUSD', @@ -1475,7 +1582,7 @@ export const mainnetTokens = defineTokens({ 'https://www.trueusd.com/', ), mtrg: new Token( - MAINNET, + ChainId.BSC, '0xBd2949F67DcdC549c6Ebe98696449Fa79D988A9F', 18, 'MTRG', @@ -1483,7 +1590,7 @@ export const mainnetTokens = defineTokens({ 'https://www.meter.io/', ), ktn: new Token( - MAINNET, + ChainId.BSC, '0xDAe6c2A48BFAA66b43815c5548b10800919c993E', 18, 'KTN', @@ -1491,7 +1598,7 @@ export const mainnetTokens = defineTokens({ 'https://kattana.io/', ), qkc: new Token( - MAINNET, + ChainId.BSC, '0xA1434F1FC3F437fa33F7a781E041961C0205B5Da', 18, 'QKC', @@ -1499,16 +1606,23 @@ export const mainnetTokens = defineTokens({ 'https://quarkchain.io/', ), bcfx: new Token( - MAINNET, + ChainId.BSC, '0x045c4324039dA91c52C55DF5D785385Aab073DcF', 18, 'bCFX', - 'BSC Conflux Token', + 'ChainId.BSC Conflux Token', 'https://www.confluxnetwork.org/', ), - mx: new Token(MAINNET, '0x9F882567A62a5560d147d64871776EeA72Df41D3', 18, 'MX', 'MX Token', 'https://www.mxc.com/'), + mx: new Token( + ChainId.BSC, + '0x9F882567A62a5560d147d64871776EeA72Df41D3', + 18, + 'MX', + 'MX Token', + 'https://www.mxc.com/', + ), ata: new Token( - MAINNET, + ChainId.BSC, '0xA2120b9e674d3fC3875f415A7DF52e382F141225', 18, 'ATA', @@ -1516,7 +1630,7 @@ export const mainnetTokens = defineTokens({ 'https://www.ata.network/', ), mbox: new Token( - MAINNET, + ChainId.BSC, '0x3203c9E46cA618C8C1cE5dC67e7e9D75f5da2377', 18, 'MBOX', @@ -1524,7 +1638,7 @@ export const mainnetTokens = defineTokens({ 'https://www.mobox.io/#/', ), boring: new Token( - MAINNET, + ChainId.BSC, '0xffEecbf8D7267757c2dc3d13D730E97E15BfdF7F', 18, 'BORING', @@ -1532,7 +1646,7 @@ export const mainnetTokens = defineTokens({ 'https://www.boringdao.com/', ), marsh: new Token( - MAINNET, + ChainId.BSC, '0x2FA5dAF6Fe0708fBD63b1A7D1592577284f52256', 18, 'MARSH', @@ -1540,7 +1654,7 @@ export const mainnetTokens = defineTokens({ 'https://unmarshal.io/', ), ampl: new Token( - MAINNET, + ChainId.BSC, '0xDB021b1B247fe2F1fa57e0A87C748Cc1E321F07F', 9, 'AMPL', @@ -1548,16 +1662,23 @@ export const mainnetTokens = defineTokens({ 'https://www.ampleforth.org/', ), o3: new Token( - MAINNET, + ChainId.BSC, '0xEe9801669C6138E84bD50dEB500827b776777d28', 18, 'O3', 'O3 Swap Token', 'https://o3swap.com/', ), - hai: new Token(MAINNET, '0xaA9E582e5751d703F85912903bacADdFed26484C', 8, 'HAI', 'Hacken Token', 'https://hacken.io/'), + hai: new Token( + ChainId.BSC, + '0xaA9E582e5751d703F85912903bacADdFed26484C', + 8, + 'HAI', + 'Hacken Token', + 'https://hacken.io/', + ), htb: new Token( - MAINNET, + ChainId.BSC, '0x4e840AADD28DA189B9906674B4Afcb77C128d9ea', 18, 'HTB', @@ -1565,7 +1686,7 @@ export const mainnetTokens = defineTokens({ 'https://www.hotbit.io/', ), woo: new Token( - MAINNET, + ChainId.BSC, '0x4691937a7508860F876c9c0a2a617E7d9E945D4B', 18, 'WOO', @@ -1573,23 +1694,15 @@ export const mainnetTokens = defineTokens({ 'https://woo.network/', ), $dg: new Token( - MAINNET, + ChainId.BSC, '0x9Fdc3ae5c814b79dcA2556564047C5e7e5449C19', 18, '$DG', 'Decentral Games Token', 'https://decentral.games/', ), - safemoon: new Token( - MAINNET, - '0x8076C74C5e3F5852037F31Ff0093Eeb8c8ADd8D3', - 9, - 'SAFEMOON', - 'Safemoon Token', - 'https://safemoon.net/', - ), axs: new Token( - MAINNET, + ChainId.BSC, '0x715D400F88C167884bbCc41C5FeA407ed4D2f8A0', 18, 'AXS', @@ -1597,7 +1710,7 @@ export const mainnetTokens = defineTokens({ 'https://axieinfinity.com/', ), c98: new Token( - MAINNET, + ChainId.BSC, '0xaEC945e04baF28b135Fa7c640f624f8D90F1C3a6', 18, 'c98', @@ -1605,7 +1718,7 @@ export const mainnetTokens = defineTokens({ 'https://coin98.com/', ), pots: new Token( - MAINNET, + ChainId.BSC, '0x3Fcca8648651E5b974DD6d3e50F61567779772A8', 18, 'POTS', @@ -1613,7 +1726,7 @@ export const mainnetTokens = defineTokens({ 'https://moonpot.com/', ), gnt: new Token( - MAINNET, + ChainId.BSC, '0xF750A26EB0aCf95556e8529E72eD530f3b60f348', 18, 'GNT', @@ -1621,7 +1734,7 @@ export const mainnetTokens = defineTokens({ 'https://www.greentrusttoken.com/', ), rusd: new Token( - MAINNET, + ChainId.BSC, '0x07663837218A003e66310a01596af4bf4e44623D', 18, 'rUSD', @@ -1629,7 +1742,7 @@ export const mainnetTokens = defineTokens({ 'https://appv2.rampdefi.com/#/', ), bp: new Token( - MAINNET, + ChainId.BSC, '0xACB8f52DC63BB752a51186D1c55868ADbFfEe9C1', 18, 'BP', @@ -1637,7 +1750,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bunnypark.com/', ), sfund: new Token( - MAINNET, + ChainId.BSC, '0x477bC8d23c634C154061869478bce96BE6045D12', 18, 'SFUND', @@ -1645,7 +1758,7 @@ export const mainnetTokens = defineTokens({ 'https://seedify.fund/', ), naos: new Token( - MAINNET, + ChainId.BSC, '0x758d08864fB6cCE3062667225ca10b8F00496cc2', 18, 'NAOS', @@ -1653,7 +1766,7 @@ export const mainnetTokens = defineTokens({ 'https://naos.finance/', ), cart: new Token( - MAINNET, + ChainId.BSC, '0x5C8C8D560048F34E5f7f8ad71f2f81a89DBd273e', 18, 'CART', @@ -1661,7 +1774,7 @@ export const mainnetTokens = defineTokens({ 'https://cryptoart.ai/', ), light: new Token( - MAINNET, + ChainId.BSC, '0x037838b556d9c9d654148a284682C55bB5f56eF4', 18, 'LIGHT', @@ -1669,7 +1782,7 @@ export const mainnetTokens = defineTokens({ 'https://lightningprotocol.finance/', ), rpg: new Token( - MAINNET, + ChainId.BSC, '0xc2098a8938119A52B1F7661893c0153A6CB116d5', 18, 'RPG', @@ -1677,7 +1790,7 @@ export const mainnetTokens = defineTokens({ 'https://www.rangersprotocol.com/', ), mcb: new Token( - MAINNET, + ChainId.BSC, '0x5fE80d2CD054645b9419657d3d10d26391780A7B', 18, 'MCB', @@ -1685,16 +1798,16 @@ export const mainnetTokens = defineTokens({ 'https://mcdex.io/homepage/', ), lazio: new Token( - MAINNET, + ChainId.BSC, '0x77d547256A2cD95F32F67aE0313E450Ac200648d', 8, 'LAZIO', 'FC Lazio Fan Token', 'https://launchpad.binance.com/en/subscription/LAZIO_BNB', ), - arv: new Token(MAINNET, '0x6679eB24F59dFe111864AEc72B443d1Da666B360', 8, 'ARV', 'ARIVA', 'https://ariva.digital'), + arv: new Token(ChainId.BSC, '0x6679eB24F59dFe111864AEc72B443d1Da666B360', 8, 'ARV', 'ARIVA', 'https://ariva.digital'), moni: new Token( - MAINNET, + ChainId.BSC, '0x9573c88aE3e37508f87649f87c4dd5373C9F31e0', 18, 'MONI', @@ -1702,7 +1815,7 @@ export const mainnetTokens = defineTokens({ 'https://monstainfinite.com/', ), xms: new Token( - MAINNET, + ChainId.BSC, '0x7859B01BbF675d67Da8cD128a50D155cd881B576', 18, 'XMS', @@ -1710,7 +1823,7 @@ export const mainnetTokens = defineTokens({ 'https://marsecosystem.com/', ), zoo: new Token( - MAINNET, + ChainId.BSC, '0x1D229B958D5DDFca92146585a8711aECbE56F095', 18, 'ZOO', @@ -1718,7 +1831,7 @@ export const mainnetTokens = defineTokens({ 'https://zoogame.finance/', ), fina: new Token( - MAINNET, + ChainId.BSC, '0x426c72701833fdDBdFc06c944737C6031645c708', 18, 'FINA', @@ -1726,7 +1839,7 @@ export const mainnetTokens = defineTokens({ 'https://defina.finance/', ), dar: new Token( - MAINNET, + ChainId.BSC, '0x23CE9e926048273eF83be0A3A8Ba9Cb6D45cd978', 6, 'DAR', @@ -1734,7 +1847,7 @@ export const mainnetTokens = defineTokens({ 'https://www.minesofdalarnia.com/', ), xwg: new Token( - MAINNET, + ChainId.BSC, '0x6b23C89196DeB721e6Fd9726E6C76E4810a464bc', 18, 'XWG', @@ -1742,7 +1855,7 @@ export const mainnetTokens = defineTokens({ 'https://xwg.games/', ), eternal: new Token( - MAINNET, + ChainId.BSC, '0xD44FD09d74cd13838F137B590497595d6b3FEeA4', 18, 'ETERNAL', @@ -1750,7 +1863,7 @@ export const mainnetTokens = defineTokens({ 'https://cryptomines.app/', ), porto: new Token( - MAINNET, + ChainId.BSC, '0x49f2145d6366099e13B10FbF80646C0F377eE7f6', 8, 'PORTO', @@ -1758,16 +1871,16 @@ export const mainnetTokens = defineTokens({ 'https://launchpad.binance.com/en/subscription/PORTO_BNB', ), kart: new Token( - MAINNET, + ChainId.BSC, '0x8BDd8DBcBDf0C066cA5f3286d33673aA7A553C10', 18, 'KART', 'Dragon Kart', 'https://dragonkart.com/', ), - qi: new Token(MAINNET, '0x8729438EB15e2C8B576fCc6AeCdA6A148776C0F5', 18, 'QI', 'BENQI', 'https://benqi.fi/'), + qi: new Token(ChainId.BSC, '0x8729438EB15e2C8B576fCc6AeCdA6A148776C0F5', 18, 'QI', 'BENQI', 'https://benqi.fi/'), sheesha: new Token( - MAINNET, + ChainId.BSC, '0x232FB065D9d24c34708eeDbF03724f2e95ABE768', 18, 'SHEESHA', @@ -1775,7 +1888,7 @@ export const mainnetTokens = defineTokens({ 'https://www.sheeshafinance.io/', ), bcoin: new Token( - MAINNET, + ChainId.BSC, '0x00e1656e45f18ec6747F5a8496Fd39B50b38396D', 18, 'BCOIN', @@ -1783,7 +1896,7 @@ export const mainnetTokens = defineTokens({ 'https://bombcrypto.io/', ), quidd: new Token( - MAINNET, + ChainId.BSC, '0x7961Ade0a767c0E5B67Dd1a1F78ba44F727642Ed', 18, 'QUIDD', @@ -1791,7 +1904,7 @@ export const mainnetTokens = defineTokens({ 'https://www.quiddtoken.com/', ), santos: new Token( - MAINNET, + ChainId.BSC, '0xA64455a4553C9034236734FadDAddbb64aCE4Cc7', 8, 'SANTOS', @@ -1799,7 +1912,7 @@ export const mainnetTokens = defineTokens({ 'https://launchpad.binance.com/en/launchpool/SANTOS_BNB', ), nabox: new Token( - MAINNET, + ChainId.BSC, '0x755f34709E369D37C6Fa52808aE84A32007d1155', 18, 'NABOX', @@ -1807,7 +1920,7 @@ export const mainnetTokens = defineTokens({ 'https://nabox.io/', ), xcv: new Token( - MAINNET, + ChainId.BSC, '0x4be63a9b26EE89b9a3a13fd0aA1D0b2427C135f8', 18, 'XCV', @@ -1815,7 +1928,7 @@ export const mainnetTokens = defineTokens({ 'https://xcarnival.fi/', ), idia: new Token( - MAINNET, + ChainId.BSC, '0x0b15Ddf19D47E6a86A56148fb4aFFFc6929BcB89', 18, 'IDIA', @@ -1823,7 +1936,7 @@ export const mainnetTokens = defineTokens({ 'https://impossible.finance/', ), tt: new Token( - MAINNET, + ChainId.BSC, '0x990E7154bB999FAa9b2fa5Ed29E822703311eA85', 18, 'TT', @@ -1831,16 +1944,23 @@ export const mainnetTokens = defineTokens({ 'https://www.thundercore.com/', ), gmee: new Token( - MAINNET, + ChainId.BSC, '0x84e9a6F9D240FdD33801f7135908BfA16866939A', 18, 'GMEE', 'GAMEE', 'https://www.gamee.com/token', ), - htd: new Token(MAINNET, '0x5E2689412Fae5c29BD575fbe1d5C1CD1e0622A8f', 18, 'HTD', 'HeroesTD', 'https://heroestd.io/'), + htd: new Token( + ChainId.BSC, + '0x5E2689412Fae5c29BD575fbe1d5C1CD1e0622A8f', + 18, + 'HTD', + 'HeroesTD', + 'https://heroestd.io/', + ), dpt: new Token( - MAINNET, + ChainId.BSC, '0xE69cAef10A488D7AF31Da46c89154d025546e990', 18, 'DPT', @@ -1848,7 +1968,7 @@ export const mainnetTokens = defineTokens({ 'https://diviner.finance/', ), thg: new Token( - MAINNET, + ChainId.BSC, '0x9fD87aEfe02441B123c3c32466cD9dB4c578618f', 18, 'THG', @@ -1856,7 +1976,7 @@ export const mainnetTokens = defineTokens({ 'https://thetanarena.com/', ), ccar: new Token( - MAINNET, + ChainId.BSC, '0x50332bdca94673F33401776365b66CC4e81aC81d', 18, 'CCAR', @@ -1864,7 +1984,7 @@ export const mainnetTokens = defineTokens({ 'https://cryptocars.me/', ), high: new Token( - MAINNET, + ChainId.BSC, '0x5f4Bde007Dc06b867f86EBFE4802e34A1fFEEd63', 18, 'HIGH', @@ -1872,16 +1992,23 @@ export const mainnetTokens = defineTokens({ 'https://highstreet.market/', ), sdao: new Token( - MAINNET, + ChainId.BSC, '0x90Ed8F1dc86388f14b64ba8fb4bbd23099f18240', 18, 'SDAO', 'Singularity Dao', 'https://app.singularitydao.ai/', ), - antex: new Token(MAINNET, '0xCA1aCAB14e85F30996aC83c64fF93Ded7586977C', 8, 'ANTEX', 'Antex', 'https://antex.org/'), + antex: new Token( + ChainId.BSC, + '0xCA1aCAB14e85F30996aC83c64fF93Ded7586977C', + 8, + 'ANTEX', + 'Antex', + 'https://antex.org/', + ), bbt: new Token( - MAINNET, + ChainId.BSC, '0xD48474E7444727bF500a32D5AbE01943f3A59A64', 8, 'BBT', @@ -1889,7 +2016,7 @@ export const mainnetTokens = defineTokens({ 'https://www.bitbook.network/', ), woop: new Token( - MAINNET, + ChainId.BSC, '0x8b303d5BbfBbf46F1a4d9741E491e06986894e18', 18, 'WOOP', @@ -1897,7 +2024,7 @@ export const mainnetTokens = defineTokens({ 'https://www.woonkly.com/', ), gm: new Token( - MAINNET, + ChainId.BSC, '0xe2604C9561D490624AA35e156e65e590eB749519', 18, 'GM', @@ -1905,7 +2032,7 @@ export const mainnetTokens = defineTokens({ 'https://goldminer.games/', ), aog: new Token( - MAINNET, + ChainId.BSC, '0x40C8225329Bd3e28A043B029E0D07a5344d2C27C', 18, 'AOG', @@ -1913,7 +2040,7 @@ export const mainnetTokens = defineTokens({ 'https://ageofgods.net/', ), '8pay': new Token( - MAINNET, + ChainId.BSC, '0xFeea0bDd3D07eb6FE305938878C0caDBFa169042', 18, '8PAY', @@ -1921,7 +2048,7 @@ export const mainnetTokens = defineTokens({ 'https://8pay.network/', ), bath: new Token( - MAINNET, + ChainId.BSC, '0x0bc89aa98Ad94E6798Ec822d0814d934cCD0c0cE', 18, 'BATH', @@ -1929,7 +2056,7 @@ export const mainnetTokens = defineTokens({ 'https://battlehero.io/', ), insur: new Token( - MAINNET, + ChainId.BSC, '0x3192CCDdf1CDcE4Ff055EbC80f3F0231b86A7E30', 18, 'INSUR', @@ -1937,7 +2064,7 @@ export const mainnetTokens = defineTokens({ 'https://www.insurace.io/', ), froyo: new Token( - MAINNET, + ChainId.BSC, '0xe369fec23380f9F14ffD07a1DC4b7c1a9fdD81c9', 18, 'FROYO', @@ -1945,7 +2072,7 @@ export const mainnetTokens = defineTokens({ 'https://froyo.games/', ), apx: new Token( - MAINNET, + ChainId.BSC, '0x78F5d389F5CDCcFc41594aBaB4B0Ed02F31398b3', 18, 'APX', @@ -1953,16 +2080,23 @@ export const mainnetTokens = defineTokens({ 'https://www.apollox.finance/', ), prl: new Token( - MAINNET, + ChainId.BSC, '0xd07e82440A395f3F3551b42dA9210CD1Ef4f8B24', 18, 'PRL', 'Parallel Token', 'https://theparallel.io', ), - fuse: new Token(MAINNET, '0x5857c96DaE9cF8511B08Cb07f85753C472D36Ea3', 18, 'FUSE', 'Fuse Token', 'https://fuse.io/'), + fuse: new Token( + ChainId.BSC, + '0x5857c96DaE9cF8511B08Cb07f85753C472D36Ea3', + 18, + 'FUSE', + 'Fuse Token', + 'https://fuse.io/', + ), ertha: new Token( - MAINNET, + ChainId.BSC, '0x62823659d09F9F9D2222058878f89437425eB261', 18, 'ERTHA', @@ -1970,7 +2104,7 @@ export const mainnetTokens = defineTokens({ 'https://ertha.io/', ), raca: new Token( - MAINNET, + ChainId.BSC, '0x12BB890508c125661E03b09EC06E404bc9289040', 18, 'RACA', @@ -1978,7 +2112,7 @@ export const mainnetTokens = defineTokens({ 'https://www.radiocaca.com/#/home', ), gear: new Token( - MAINNET, + ChainId.BSC, '0xb4404DaB7C0eC48b428Cf37DeC7fb628bcC41B36', 18, 'GEAR', @@ -1986,7 +2120,7 @@ export const mainnetTokens = defineTokens({ 'https://metagear.game/', ), ach: new Token( - MAINNET, + ChainId.BSC, '0xBc7d6B50616989655AfD682fb42743507003056D', 8, 'ACH', @@ -1994,16 +2128,23 @@ export const mainnetTokens = defineTokens({ 'https://alchemytech.io/', ), btt: new Token( - MAINNET, + ChainId.BSC, '0x352Cb5E19b12FC216548a2677bD0fce83BaE434B', 18, 'BTT', 'BitTorrent', 'https://bittorrent.com/', ), - era: new Token(MAINNET, '0x6f9F0c4ad9Af7EbD61Ac5A1D4e0F2227F7B0E5f9', 18, 'ERA', 'Era Token', 'https://www.era7.io/'), + era: new Token( + ChainId.BSC, + '0x6f9F0c4ad9Af7EbD61Ac5A1D4e0F2227F7B0E5f9', + 18, + 'ERA', + 'Era Token', + 'https://www.era7.io/', + ), fight: new Token( - MAINNET, + ChainId.BSC, '0x4f39c3319188A723003670c3F9B9e7EF991E52F3', 18, 'FIGHT', @@ -2011,7 +2152,7 @@ export const mainnetTokens = defineTokens({ 'https://www.cryptofightclub.io/', ), loa: new Token( - MAINNET, + ChainId.BSC, '0x94b69263FCA20119Ae817b6f783Fc0F13B02ad50', 18, 'LOA', @@ -2019,7 +2160,7 @@ export const mainnetTokens = defineTokens({ 'https://www.leagueofancients.com/', ), duet: new Token( - MAINNET, + ChainId.BSC, '0x95EE03e1e2C5c4877f9A298F1C0D6c98698FAB7B', 18, 'DUET', @@ -2027,26 +2168,33 @@ export const mainnetTokens = defineTokens({ 'https://duet.finance', ), gmt: new Token( - MAINNET, + ChainId.BSC, '0x3019BF2a2eF8040C242C9a4c5c4BD4C81678b2A1', 8, 'GMT', 'Green Metaverse Token', 'https://www.stepn.com/', ), - bsw: new Token(MAINNET, '0x965F527D9159dCe6288a2219DB51fc6Eef120dD1', 18, 'BSW', 'Biswap', 'https://biswap.org/'), + bsw: new Token(ChainId.BSC, '0x965F527D9159dCe6288a2219DB51fc6Eef120dD1', 18, 'BSW', 'Biswap', 'https://biswap.org/'), tem: new Token( - MAINNET, + ChainId.BSC, '0x19e6BfC1A6e4B042Fb20531244D47E252445df01', 9, 'TEM', 'TemplarDAO', 'https://templar.finance/', ), - pex: new Token(MAINNET, '0x6a0b66710567b6beb81A71F7e9466450a91a384b', 18, 'PEX', 'PearDAO', 'https://peardao.io/'), - yel: new Token(MAINNET, '0xD3b71117E6C1558c1553305b44988cd944e97300', 18, 'YEL', 'YEL', 'https://yel.finance/'), + pex: new Token( + ChainId.BSC, + '0x6a0b66710567b6beb81A71F7e9466450a91a384b', + 18, + 'PEX', + 'PearDAO', + 'https://peardao.io/', + ), + yel: new Token(ChainId.BSC, '0xD3b71117E6C1558c1553305b44988cd944e97300', 18, 'YEL', 'YEL', 'https://yel.finance/'), tinc: new Token( - MAINNET, + ChainId.BSC, '0x05aD6E30A855BE07AfA57e08a4f30d00810a402e', 18, 'TINC', @@ -2054,7 +2202,7 @@ export const mainnetTokens = defineTokens({ 'https://tinyworlds.io/', ), happy: new Token( - MAINNET, + ChainId.BSC, '0xF5d8A096CcCb31b9D7bcE5afE812BE23e3D4690d', 18, 'Happy', @@ -2062,34 +2210,48 @@ export const mainnetTokens = defineTokens({ 'https://happyfans.club/', ), wzrd: new Token( - MAINNET, + ChainId.BSC, '0xFa40d8FC324bcdD6Bbae0e086De886c571C225d4', 18, 'WZRD', 'Wizardia Token', 'https://wizardia.io/', ), - ceek: new Token(MAINNET, '0xe0F94Ac5462997D2BC57287Ac3a3aE4C31345D66', 18, 'CEEK', 'CEEK', 'https://www.ceek.com/'), + ceek: new Token( + ChainId.BSC, + '0xe0F94Ac5462997D2BC57287Ac3a3aE4C31345D66', + 18, + 'CEEK', + 'CEEK', + 'https://www.ceek.com/', + ), abnbc: new Token( - MAINNET, + ChainId.BSC, '0xE85aFCcDaFBE7F2B096f268e31ccE3da8dA2990A', 18, 'aBNBc', 'Ankr BNB Reward Bearing Certificate', 'https://www.ankr.com/', ), - ankr: new Token(MAINNET, '0xf307910A4c7bbc79691fD374889b36d8531B08e3', 18, 'ANKR', 'Ankr', 'https://www.ankr.com/'), + ankr: new Token( + ChainId.BSC, + '0xf307910A4c7bbc79691fD374889b36d8531B08e3', + 18, + 'ANKR', + 'Ankr', + 'https://www.ankr.com/', + ), gal: new Token( - MAINNET, + ChainId.BSC, '0xe4Cc45Bb5DBDA06dB6183E8bf016569f40497Aa5', 18, 'GAL', 'Project Galaxy', 'https://galaxy.eco/', ), - xcn: new Token(MAINNET, '0x7324c7C0d95CEBC73eEa7E85CbAac0dBdf88a05b', 18, 'XCN', 'Chain', 'https://chain.com/'), + xcn: new Token(ChainId.BSC, '0x7324c7C0d95CEBC73eEa7E85CbAac0dBdf88a05b', 18, 'XCN', 'Chain', 'https://chain.com/'), metis: new Token( - MAINNET, + ChainId.BSC, '0xe552Fb52a4F19e44ef5A967632DBc320B0820639', 18, 'Metis', @@ -2097,7 +2259,7 @@ export const mainnetTokens = defineTokens({ 'https://www.metis.io/', ), MIX: new Token( - MAINNET, + ChainId.BSC, '0x398f7827DcCbeFe6990478876bBF3612D93baF05', 18, 'MIX', @@ -2105,7 +2267,7 @@ export const mainnetTokens = defineTokens({ 'https://www.mixmarvel.com/', ), peak: new Token( - MAINNET, + ChainId.BSC, '0x630d98424eFe0Ea27fB1b3Ab7741907DFFEaAd78', 8, 'PEAK', @@ -2113,7 +2275,7 @@ export const mainnetTokens = defineTokens({ 'https://peakdefi.com/', ), nbt: new Token( - MAINNET, + ChainId.BSC, '0x1D3437E570e93581Bd94b2fd8Fbf202d4a65654A', 18, 'NBT', @@ -2121,7 +2283,7 @@ export const mainnetTokens = defineTokens({ 'https://www.nanobyte.finance/', ), trivia: new Token( - MAINNET, + ChainId.BSC, '0xb465f3cb6Aba6eE375E12918387DE1eaC2301B05', 3, 'TRIVIA', @@ -2129,7 +2291,7 @@ export const mainnetTokens = defineTokens({ 'https://trivians.io/', ), mhunt: new Token( - MAINNET, + ChainId.BSC, '0x2C717059b366714d267039aF8F59125CAdce6D8c', 18, 'MHUNT', @@ -2137,7 +2299,7 @@ export const mainnetTokens = defineTokens({ 'https://metashooter.gg/', ), ole: new Token( - MAINNET, + ChainId.BSC, '0xa865197A84E780957422237B5D152772654341F3', 18, 'OLE', @@ -2145,7 +2307,7 @@ export const mainnetTokens = defineTokens({ 'https://openleverage.finance/', ), xcad: new Token( - MAINNET, + ChainId.BSC, '0x431e0cD023a32532BF3969CddFc002c00E98429d', 18, 'XCAD', @@ -2153,42 +2315,21 @@ export const mainnetTokens = defineTokens({ 'https://xcadnetwork.com/', ), shell: new Token( - MAINNET, + ChainId.BSC, '0x208cfEc94d2BA8B8537da7A9BB361c6baAD77272', 18, 'SHELL', 'Meta Apes Shell', 'https://metaapesgame.com/', ), -} as const) +} -export const testnetTokens = defineTokens({ - wbnb: new Token( - TESTNET, - '0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd', - 18, - 'WBNB', - 'Wrapped BNB', - 'https://www.binance.com/', - ), - cake: new Token( - TESTNET, - '0xa35062141Fa33BCA92Ce69FeD37D0E8908868AAe', - 18, - 'CAKE', - 'PancakeSwap Token', - 'https://pancakeswap.finance/', - ), - busd: new Token( - TESTNET, - '0xeD24FC36d5Ee211Ea25A80239Fb8C4Cfd80f12Ee', - 18, - 'BUSD', - 'Binance USD', - 'https://www.paxos.com/busd/', - ), +export const bscTestnetTokens = { + wbnb: WBNB[ChainId.BSC_TESTNET], + cake: CAKE_TESTNET, + busd: BUSD_TESTNET, syrup: new Token( - TESTNET, + ChainId.BSC_TESTNET, '0xfE1e507CeB712BDe086f3579d2c03248b2dB77f9', 18, 'SYRUP', @@ -2196,36 +2337,11 @@ export const testnetTokens = defineTokens({ 'https://pancakeswap.finance/', ), bake: new Token( - TESTNET, + ChainId.BSC_TESTNET, '0xE02dF9e3e622DeBdD69fb838bB799E3F168902c5', 18, 'BAKE', 'Bakeryswap Token', 'https://www.bakeryswap.org/', ), -} as const) - -const tokens = () => { - // If testnet - return list comprised of testnetTokens wherever they exist, and mainnetTokens where they don't - if (parseInt(CHAIN_ID, 10) === ChainId.TESTNET) { - return Object.keys(mainnetTokens).reduce((accum, key) => { - return { ...accum, [key]: testnetTokens[key] || mainnetTokens[key] } - }, {} as typeof testnetTokens & typeof mainnetTokens) - } - - return mainnetTokens -} - -const unserializedTokens = tokens() - -type SerializedTokenList = Record - -export const serializeTokens = () => { - const serializedTokens = Object.keys(unserializedTokens).reduce((accum, key) => { - return { ...accum, [key]: serializeToken(unserializedTokens[key]) } - }, {} as SerializedTokenList) - - return serializedTokens } - -export default unserializedTokens diff --git a/src/config/constants/types.ts b/src/config/constants/types.ts index 07690316e..ff4dd5784 100644 --- a/src/config/constants/types.ts +++ b/src/config/constants/types.ts @@ -17,6 +17,7 @@ export type TranslatableText = export interface Address { 97?: string 56: string + [chainId: number]: string } export interface SerializedToken { diff --git a/src/config/constants/warningTokens.ts b/src/config/constants/warningTokens.ts index 47f454b2d..bc1b4e56c 100644 --- a/src/config/constants/warningTokens.ts +++ b/src/config/constants/warningTokens.ts @@ -1,27 +1,16 @@ import { ChainId, Token } from '@pancakeswap/sdk' -import { CHAIN_ID } from './networks' -import { defineTokens } from './tokens' -const { MAINNET } = ChainId - -export const mainnetTokens = defineTokens({ - pokemoney: new Token(MAINNET, '0x32ff5b4C3B1744F0344D96fA2f87799Ed2805749', 18, 'PMY', 'Pokemoney Coin', ''), - free: new Token(MAINNET, '0x880BCe9321c79cAc1D290De6d31DDE722C606165', 8, 'FREE', 'Freedom Protocol Token', ''), -} as const) - -export const testnetTokens = defineTokens({} as const) - -const tokens = () => { - // If testnet - return list comprised of testnetTokens wherever they exist, and mainnetTokens where they don't - if (parseInt(CHAIN_ID, 10) === ChainId.TESTNET) { - return Object.keys(mainnetTokens).reduce((accum, key) => { - return { ...accum, [key]: testnetTokens[key] || mainnetTokens[key] } - }, {} as typeof testnetTokens & typeof mainnetTokens) - } - - return mainnetTokens +export const bscWarningTokens = { + pokemoney: new Token(ChainId.BSC, '0x32ff5b4C3B1744F0344D96fA2f87799Ed2805749', 18, 'PMY', 'Pokemoney Coin', ''), + free: new Token(ChainId.BSC, '0x880BCe9321c79cAc1D290De6d31DDE722C606165', 8, 'FREE', 'Freedom Protocol Token', ''), + safemoon: new Token( + ChainId.BSC, + '0x8076C74C5e3F5852037F31Ff0093Eeb8c8ADd8D3', + 9, + 'SAFEMOON', + 'Safemoon Token', + 'https://safemoon.net/', + ), } -const unserializedTokens = tokens() - -export default unserializedTokens +export const bscTestnetWarningTokens = {} diff --git a/src/config/index.ts b/src/config/index.ts index a71be50c7..90763a85e 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -10,8 +10,8 @@ BigNumber.config({ export const BSC_BLOCK_TIME = 3 export const BASE_BSC_SCAN_URLS = { - [ChainId.MAINNET]: 'https://bscscan.com', - [ChainId.TESTNET]: 'https://testnet.bscscan.com', + [ChainId.BSC]: 'https://bscscan.com', + [ChainId.BSC_TESTNET]: 'https://testnet.bscscan.com', } // CAKE_PER_BLOCK details @@ -26,7 +26,7 @@ export const BLOCKS_PER_YEAR = (60 / BSC_BLOCK_TIME) * 60 * 24 * 365 // 10512000 export const CAKE_PER_YEAR = CAKE_PER_BLOCK * BLOCKS_PER_YEAR export const BASE_URL = 'https://pancakeswap.finance' export const BASE_ADD_LIQUIDITY_URL = `${BASE_URL}/add` -export const BASE_BSC_SCAN_URL = BASE_BSC_SCAN_URLS[ChainId.MAINNET] +export const BASE_BSC_SCAN_URL = BASE_BSC_SCAN_URLS[ChainId.BSC] export const DEFAULT_TOKEN_DECIMAL = BIG_TEN.pow(18) export const DEFAULT_GAS_LIMIT = 250000 export const AUCTION_BIDDERS_TO_FETCH = 500 diff --git a/src/config/localization/translations.json b/src/config/localization/translations.json index 034600558..c7eea9b6f 100644 --- a/src/config/localization/translations.json +++ b/src/config/localization/translations.json @@ -446,7 +446,6 @@ "Transfer": "Transfer", "Congratulations!": "Congratulations!", "Claim now": "Claim now", - "Claiming...": "Claiming...", "Receiving address": "Receiving address", "Could not retrieve CAKE costs for profile": "Could not retrieve CAKE costs for profile", "Provider Error": "Provider Error", @@ -1649,7 +1648,6 @@ "Released": "Released", "Vested": "Vested", "You will be able to withdraw the staked CAKE and profit only when the staking position is unlocked": "You will be able to withdraw the staked CAKE and profit only when the staking position is unlocked", - "Failed to claim": "Failed to claim", "Hello, early fixed-term staking pool CAKE lovers.": "Hello, early fixed-term staking pool CAKE lovers.", "If you staked in our fixed-term staking pool for 52 weeks within the first 24 hours of the launch, you are eligible to claim a special edition “Project Galaxy x PancakeSwap” NFT.": "If you staked in our fixed-term staking pool for 52 weeks within the first 24 hours of the launch, you are eligible to claim a special edition “Project Galaxy x PancakeSwap” NFT.", "Hold this NFT in your wallet until the snapshot timing (10:00 UTC 11th May 2022) to participate in the $GAL airdrop with a total of 400,000 GAL tokens.": "Hold this NFT in your wallet until the snapshot timing (10:00 UTC 11th May 2022) to participate in the $GAL airdrop with a total of 400,000 GAL tokens.", diff --git a/src/hooks/Tokens.ts b/src/hooks/Tokens.ts index 57a4b592f..1c8afb830 100644 --- a/src/hooks/Tokens.ts +++ b/src/hooks/Tokens.ts @@ -4,7 +4,6 @@ import { parseBytes32String } from '@ethersproject/strings' import { Currency, currencyEquals, ETHER, Token } from '@pancakeswap/sdk' import { createSelector } from '@reduxjs/toolkit' import { GELATO_NATIVE } from 'config/constants' -import { CHAIN_ID } from 'config/constants/networks' import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useMemo } from 'react' import { useSelector } from 'react-redux' @@ -20,72 +19,78 @@ import useUserAddedTokens, { userAddedTokenSelector } from '../state/user/hooks/ import { isAddress } from '../utils' import { useBytes32TokenContract, useTokenContract } from './useContract' -const mapWithoutUrls = (tokenMap: TokenAddressMap) => - Object.keys(tokenMap[CHAIN_ID]).reduce<{ [address: string]: Token }>((newMap, address) => { - newMap[address] = tokenMap[CHAIN_ID][address].token +const mapWithoutUrls = (tokenMap: TokenAddressMap, chainId: number) => + Object.keys(tokenMap[chainId]).reduce<{ [address: string]: Token }>((newMap, address) => { + newMap[address] = tokenMap[chainId][address].token return newMap }, {}) -const allTokenSelector = createSelector( - [combinedTokenMapFromActiveUrlsSelector, userAddedTokenSelector], - (tokenMap, userAddedTokens) => { - return ( - userAddedTokens - // reduce into all ALL_TOKENS filtered by the current chain - .reduce<{ [address: string]: Token }>( - (tokenMap_, token) => { - tokenMap_[token.address] = token - return tokenMap_ - }, - // must make a copy because reduce modifies the map, and we do not - // want to make a copy in every iteration - mapWithoutUrls(tokenMap), - ) - ) - }, -) - -const allOfficialsAndUserAddedTokensSelector = createSelector( - [combinedTokenMapFromOfficialsUrlsSelector, userAddedTokenSelector], - (tokenMap, userAddedTokens) => { - return ( - userAddedTokens - // reduce into all ALL_TOKENS filtered by the current chain - .reduce<{ [address: string]: Token }>( - (tokenMap_, token) => { - tokenMap_[token.address] = token - return tokenMap_ - }, - // must make a copy because reduce modifies the map, and we do not - // want to make a copy in every iteration - mapWithoutUrls(tokenMap), - ) - ) - }, -) +const allTokenSelector = (chainId: number) => + createSelector( + [combinedTokenMapFromActiveUrlsSelector, userAddedTokenSelector(chainId)], + (tokenMap, userAddedTokens) => { + return ( + userAddedTokens + // reduce into all ALL_TOKENS filtered by the current chain + .reduce<{ [address: string]: Token }>( + (tokenMap_, token) => { + tokenMap_[token.address] = token + return tokenMap_ + }, + // must make a copy because reduce modifies the map, and we do not + // want to make a copy in every iteration + mapWithoutUrls(tokenMap, chainId), + ) + ) + }, + ) + +const allOfficialsAndUserAddedTokensSelector = (chainId: number) => + createSelector( + [combinedTokenMapFromOfficialsUrlsSelector, userAddedTokenSelector(chainId)], + (tokenMap, userAddedTokens) => { + return ( + userAddedTokens + // reduce into all ALL_TOKENS filtered by the current chain + .reduce<{ [address: string]: Token }>( + (tokenMap_, token) => { + tokenMap_[token.address] = token + return tokenMap_ + }, + // must make a copy because reduce modifies the map, and we do not + // want to make a copy in every iteration + mapWithoutUrls(tokenMap, chainId), + ) + ) + }, + ) /** * Returns all tokens that are from active urls and user added tokens */ export function useAllTokens(): { [address: string]: Token } { - return useSelector(allTokenSelector) + const { chainId } = useActiveWeb3React() + return useSelector(allTokenSelector(chainId)) } /** * Returns all tokens that are from officials token list and user added tokens */ export function useOfficialsAndUserAddedTokens(): { [address: string]: Token } { - return useSelector(allOfficialsAndUserAddedTokensSelector) + const { chainId } = useActiveWeb3React() + return useSelector(allOfficialsAndUserAddedTokensSelector(chainId)) } export function useUnsupportedTokens(): { [address: string]: Token } { + const { chainId } = useActiveWeb3React() const unsupportedTokensMap = useUnsupportedTokenList() - return useMemo(() => mapWithoutUrls(unsupportedTokensMap), [unsupportedTokensMap]) + return useMemo(() => mapWithoutUrls(unsupportedTokensMap, chainId), [unsupportedTokensMap, chainId]) } export function useWarningTokens(): { [address: string]: Token } { const warningTokensMap = useWarningTokenList() - return useMemo(() => mapWithoutUrls(warningTokensMap), [warningTokensMap]) + const { chainId } = useActiveWeb3React() + return useMemo(() => mapWithoutUrls(warningTokensMap, chainId), [warningTokensMap, chainId]) } export function useIsTokenActive(token: Token | undefined | null): boolean { diff --git a/src/hooks/Trades.test.ts b/src/hooks/Trades.test.ts index e16abba6b..bd446b85a 100644 --- a/src/hooks/Trades.test.ts +++ b/src/hooks/Trades.test.ts @@ -1,5 +1,5 @@ import { renderHook } from '@testing-library/react-hooks' -import { mainnetTokens } from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { createReduxWrapper } from 'testUtils' import { Pair, TokenAmount, CurrencyAmount, Trade } from '@pancakeswap/sdk' import * as UsePairs from './usePairs' @@ -12,65 +12,47 @@ describe('Trade', () => { const mockUsePairs = jest.spyOn(UsePairs, 'usePairs') it('should filter only exist Pair', () => { mockUsePairs.mockReturnValue([ - [ - PairState.EXISTS, - new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1')), - ], - [ - PairState.INVALID, - new Pair(new TokenAmount(mainnetTokens.busd, '1'), new TokenAmount(mainnetTokens.cake, '1')), - ], - [ - PairState.LOADING, - new Pair(new TokenAmount(mainnetTokens.busd, '1'), new TokenAmount(mainnetTokens.wbnb, '1')), - ], + [PairState.EXISTS, new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1'))], + [PairState.INVALID, new Pair(new TokenAmount(bscTokens.busd, '1'), new TokenAmount(bscTokens.cake, '1'))], + [PairState.LOADING, new Pair(new TokenAmount(bscTokens.busd, '1'), new TokenAmount(bscTokens.wbnb, '1'))], [PairState.EXISTS, null], ]) const { result } = renderHook(() => { - const pairs = Trades.useAllCommonPairs(mainnetTokens.wbnb, mainnetTokens.cake) + const pairs = Trades.useAllCommonPairs(bscTokens.wbnb, bscTokens.cake) return { pairs, } }) expect(result.current.pairs).toStrictEqual([ - new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1')), + new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1')), ]) }) it('should filter out duplicated Pair', () => { mockUsePairs.mockReturnValue([ - [ - PairState.EXISTS, - new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1')), - ], - [ - PairState.EXISTS, - new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1')), - ], - [ - PairState.EXISTS, - new Pair(new TokenAmount(mainnetTokens.cake, '1'), new TokenAmount(mainnetTokens.wbnb, '1')), - ], + [PairState.EXISTS, new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1'))], + [PairState.EXISTS, new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1'))], + [PairState.EXISTS, new Pair(new TokenAmount(bscTokens.cake, '1'), new TokenAmount(bscTokens.wbnb, '1'))], [PairState.EXISTS, null], ]) const { result } = renderHook(() => { - const pairs = Trades.useAllCommonPairs(mainnetTokens.wbnb, mainnetTokens.cake) + const pairs = Trades.useAllCommonPairs(bscTokens.wbnb, bscTokens.cake) return { pairs, } }) expect(result.current.pairs).toStrictEqual([ - new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1')), + new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1')), ]) }) it('should get all pair combinations wbnb, cake', () => { mockUsePairs.mockClear() renderHook(() => { - Trades.useAllCommonPairs(mainnetTokens.wbnb, mainnetTokens.cake) + Trades.useAllCommonPairs(bscTokens.wbnb, bscTokens.cake) }) expect(mockUsePairs).toMatchSnapshot() @@ -79,7 +61,7 @@ describe('Trade', () => { it('should get all pair combinations, wbnb, wbnb', () => { mockUsePairs.mockClear() renderHook(() => { - Trades.useAllCommonPairs(mainnetTokens.wbnb, mainnetTokens.wbnb) + Trades.useAllCommonPairs(bscTokens.wbnb, bscTokens.wbnb) }) expect(mockUsePairs).toMatchSnapshot() @@ -92,9 +74,9 @@ describe('Trade', () => { const mockTradeExactOut = jest.spyOn(Trade, 'bestTradeExactOut') it('should call with maxHops 1 with singleHopOnly', () => { - const allowPairs = [new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1'))] + const allowPairs = [new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1'))] const argA = CurrencyAmount.ether('1000000') - const argB = mainnetTokens.cake + const argB = bscTokens.cake renderHook( () => { mockUseAllCommonPairs.mockReturnValue(allowPairs) @@ -123,9 +105,9 @@ describe('Trade', () => { }) it('should call with 3 times without singleHopOnly', () => { - const allowPairs = [new Pair(new TokenAmount(mainnetTokens.wbnb, '1'), new TokenAmount(mainnetTokens.cake, '1'))] + const allowPairs = [new Pair(new TokenAmount(bscTokens.wbnb, '1'), new TokenAmount(bscTokens.cake, '1'))] const argA = CurrencyAmount.ether('1000000') - const argB = mainnetTokens.cake + const argB = bscTokens.cake renderHook( () => { mockUseAllCommonPairs.mockReturnValue(allowPairs) diff --git a/src/hooks/__snapshots__/Trades.test.ts.snap b/src/hooks/__snapshots__/Trades.test.ts.snap index f0f3ddacc..97a6615f5 100644 --- a/src/hooks/__snapshots__/Trades.test.ts.snap +++ b/src/hooks/__snapshots__/Trades.test.ts.snap @@ -11,7 +11,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -29,7 +29,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -47,7 +47,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -65,7 +65,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -83,7 +83,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -101,7 +101,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -119,7 +119,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -145,7 +145,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -245,7 +245,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -263,7 +263,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -281,7 +281,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -299,7 +299,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -317,7 +317,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -335,7 +335,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -361,7 +361,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -469,7 +469,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -577,7 +577,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -685,7 +685,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -793,7 +793,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -901,7 +901,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -1045,7 +1045,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, "denominator": JSBI [ @@ -1060,7 +1060,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, }, @@ -1110,7 +1110,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, "denominator": JSBI [ @@ -1125,7 +1125,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, }, @@ -1175,7 +1175,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, "denominator": JSBI [ @@ -1190,7 +1190,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations wbnb, cake 1` "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, }, @@ -1218,7 +1218,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1236,7 +1236,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1254,7 +1254,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1272,7 +1272,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1290,7 +1290,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1308,7 +1308,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1326,7 +1326,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1344,7 +1344,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1362,7 +1362,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1380,7 +1380,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1398,7 +1398,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1416,7 +1416,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1434,7 +1434,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1452,7 +1452,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1470,7 +1470,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1488,7 +1488,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1506,7 +1506,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1524,7 +1524,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, Token { @@ -1550,7 +1550,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -1658,7 +1658,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -1766,7 +1766,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -1874,7 +1874,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -1982,7 +1982,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -2090,7 +2090,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, ], @@ -2234,7 +2234,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, "denominator": JSBI [ @@ -2249,7 +2249,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, }, @@ -2299,7 +2299,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, "denominator": JSBI [ @@ -2314,7 +2314,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, }, @@ -2364,7 +2364,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, "denominator": JSBI [ @@ -2379,7 +2379,7 @@ exports[`Trade #useAllCommonPairs should get all pair combinations, wbnb, wbnb 1 "chainId": 56, "decimals": 18, "name": "Wrapped BNB", - "projectLink": "https://www.binance.com/", + "projectLink": "https://www.binance.org", "symbol": "WBNB", }, }, diff --git a/src/hooks/useActiveWeb3React.ts b/src/hooks/useActiveWeb3React.ts index edc8335b3..abd01b6b9 100644 --- a/src/hooks/useActiveWeb3React.ts +++ b/src/hooks/useActiveWeb3React.ts @@ -1,9 +1,9 @@ import { useWeb3React } from '@web3-react/core' import { Web3Provider } from '@ethersproject/providers' -import { simpleRpcProvider } from 'utils/providers' // eslint-disable-next-line import/no-unresolved import { Web3ReactContextInterface } from '@web3-react/core/dist/types' -import { CHAIN_ID } from 'config/constants/networks' +import { ChainId } from '@pancakeswap/sdk' +import { bscRpcProvider } from 'utils/providers' /** * Provides a web3 provider with or without user's signer @@ -12,7 +12,7 @@ import { CHAIN_ID } from 'config/constants/networks' const useActiveWeb3React = (): Web3ReactContextInterface => { const { library, chainId, ...web3React } = useWeb3React() - return { library: library || simpleRpcProvider, chainId: chainId ?? parseInt(CHAIN_ID, 10), ...web3React } + return { library: library ?? bscRpcProvider, chainId: chainId ?? ChainId.BSC, ...web3React } } export default useActiveWeb3React diff --git a/src/hooks/useApproveCallback.ts b/src/hooks/useApproveCallback.ts index b434f03f5..3eae4e704 100644 --- a/src/hooks/useApproveCallback.ts +++ b/src/hooks/useApproveCallback.ts @@ -1,7 +1,6 @@ import { MaxUint256 } from '@ethersproject/constants' import { TransactionResponse } from '@ethersproject/providers' import { Trade, TokenAmount, CurrencyAmount, ETHER } from '@pancakeswap/sdk' -import { CHAIN_ID } from 'config/constants/networks' import { useCallback, useMemo } from 'react' import { logError } from 'utils/sentry' import { useWeb3React } from '@web3-react/core' @@ -123,13 +122,13 @@ export function useApproveCallback( } // wraps useApproveCallback in the context of a swap -export function useApproveCallbackFromTrade(trade?: Trade, allowedSlippage = 0) { +export function useApproveCallbackFromTrade(trade?: Trade, allowedSlippage = 0, chainId?: number) { const amountToApprove = useMemo( () => (trade ? computeSlippageAdjustedAmounts(trade, allowedSlippage)[Field.INPUT] : undefined), [trade, allowedSlippage], ) - return useApproveCallback(amountToApprove, ROUTER_ADDRESS[CHAIN_ID]) + return useApproveCallback(amountToApprove, ROUTER_ADDRESS[chainId]) } // Wraps useApproveCallback in the context of a Gelato Limit Orders diff --git a/src/hooks/useAuth.tsx b/src/hooks/useAuth.tsx index 761b2f873..bbfebb6fe 100644 --- a/src/hooks/useAuth.tsx +++ b/src/hooks/useAuth.tsx @@ -35,7 +35,7 @@ const useAuth = () => { if (error instanceof UnsupportedChainIdError) { setError(error) const provider = await connector.getProvider() - const hasSetup = await setupNetwork(provider) + const hasSetup = await setupNetwork(56, provider) if (hasSetup) { activate(connector) } diff --git a/src/hooks/useBUSDPrice.ts b/src/hooks/useBUSDPrice.ts index 9285259c0..c6cb9a1a8 100644 --- a/src/hooks/useBUSDPrice.ts +++ b/src/hooks/useBUSDPrice.ts @@ -1,13 +1,11 @@ -import { Currency, currencyEquals, JSBI, Price } from '@pancakeswap/sdk' -import tokens from 'config/constants/tokens' +import { Currency, currencyEquals, JSBI, Price, WNATIVE } from '@pancakeswap/sdk' +import { CAKE, BUSD } from 'config/constants/tokens' import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useMemo } from 'react' import { multiplyPriceByAmount } from 'utils/prices' import { wrappedCurrency } from '../utils/wrappedCurrency' import { PairState, usePairs } from './usePairs' -const { wbnb: WBNB, busd } = tokens - /** * Returns the price in BUSD of the input currency * @param currency currency to compute the BUSD price of @@ -15,13 +13,16 @@ const { wbnb: WBNB, busd } = tokens export default function useBUSDPrice(currency?: Currency): Price | undefined { const { chainId } = useActiveWeb3React() const wrapped = wrappedCurrency(currency, chainId) + const WBNB = WNATIVE[chainId] + const busd = BUSD[chainId] + const tokenPairs: [Currency | undefined, Currency | undefined][] = useMemo( () => [ [chainId && wrapped && currencyEquals(WBNB, wrapped) ? undefined : currency, chainId ? WBNB : undefined], [wrapped?.equals(busd) ? undefined : wrapped, busd], [chainId ? WBNB : undefined, busd], ], - [chainId, currency, wrapped], + [WBNB, busd, chainId, currency, wrapped], ) const [[bnbPairState, bnbPair], [busdPairState, busdPair], [busdBnbPairState, busdBnbPair]] = usePairs(tokenPairs) @@ -62,11 +63,24 @@ export default function useBUSDPrice(currency?: Currency): Price | undefined { } return undefined - }, [chainId, currency, bnbPair, bnbPairState, busdBnbPair, busdBnbPairState, busdPair, busdPairState, wrapped]) + }, [ + currency, + wrapped, + chainId, + WBNB, + busd, + bnbPair, + busdBnbPair, + busdPairState, + busdPair, + bnbPairState, + busdBnbPairState, + ]) } export const useCakeBusdPrice = (): Price | undefined => { - const cakeBusdPrice = useBUSDPrice(tokens.cake) + const { chainId } = useActiveWeb3React() + const cakeBusdPrice = useBUSDPrice(CAKE[chainId]) return cakeBusdPrice } @@ -90,6 +104,7 @@ export const useBUSDCakeAmount = (amount: number): number | undefined => { } export const useBNBBusdPrice = (): Price | undefined => { - const bnbBusdPrice = useBUSDPrice(tokens.wbnb) + const { chainId } = useActiveWeb3React() + const bnbBusdPrice = useBUSDPrice(WNATIVE[chainId]) return bnbBusdPrice } diff --git a/src/hooks/useContract.ts b/src/hooks/useContract.ts index d2ea56db6..52d3974d2 100644 --- a/src/hooks/useContract.ts +++ b/src/hooks/useContract.ts @@ -35,13 +35,11 @@ import { getPancakeSquadContract, getErc721CollectionContract, getBunnySpecialXmasContract, - getGalaxyNTFClaimingContract, - getZapContract, getCakeFlexibleSideVaultV2Contract, getCakePredictionsContract, getPredictionsV1Contract, } from 'utils/contractHelpers' -import { getMulticallAddress, getPredictionsV1Address } from 'utils/addressHelpers' +import { getMulticallAddress, getPredictionsV1Address, getZapAddress } from 'utils/addressHelpers' import { Erc20, Erc20Bytes32, @@ -51,11 +49,14 @@ import { Erc721collection, CakeVaultV2, CakeFlexibleSideVaultV2, + Zap, } from 'config/abi/types' +import zapAbi from 'config/abi/zap.json' // Imports below migrated from Exchange useContract.ts import { Contract } from '@ethersproject/contracts' -import { WETH } from '@pancakeswap/sdk' +import { bscRpcProvider } from 'utils/providers' +import { ChainId, WNATIVE } from '@pancakeswap/sdk' import IPancakePairABI from '../config/abi/IPancakePair.json' import { ERC20_BYTES32_ABI } from '../config/abi/erc20' import ERC20_ABI from '../config/abi/erc20.json' @@ -284,11 +285,6 @@ export const useAnniversaryAchievementContract = () => { return useMemo(() => getAnniversaryAchievementContract(library.getSigner()), [library]) } -export const useGalaxyNFTClaimingContract = () => { - const { library } = useActiveWeb3React() - return useMemo(() => getGalaxyNTFClaimingContract(library.getSigner()), [library]) -} - export const useNftSaleContract = () => { const { library } = useActiveWeb3React() return useMemo(() => getNftSaleContract(library.getSigner()), [library]) @@ -334,10 +330,11 @@ function useContract( ABI: any, withSignerIfPossible = true, ): T | null { - const { library, account } = useActiveWeb3React() + const { library, account, chainId } = useActiveWeb3React() const signer = useMemo( - () => (withSignerIfPossible ? getProviderOrSigner(library, account) : null), - [withSignerIfPossible, library, account], + () => + withSignerIfPossible ? getProviderOrSigner(library, account) : chainId === ChainId.BSC ? bscRpcProvider : library, + [withSignerIfPossible, library, account, chainId], ) const canReturnContract = useMemo( @@ -362,7 +359,7 @@ export function useTokenContract(tokenAddress?: string, withSignerIfPossible?: b export function useWBNBContract(withSignerIfPossible?: boolean): Contract | null { const { chainId } = useActiveWeb3React() - return useContract(chainId ? WETH[chainId].address : undefined, WETH_ABI, withSignerIfPossible) + return useContract(chainId ? WNATIVE[chainId].address : undefined, WETH_ABI, withSignerIfPossible) } export function useBytes32TokenContract(tokenAddress?: string, withSignerIfPossible?: boolean): Contract | null { @@ -374,14 +371,10 @@ export function usePairContract(pairAddress?: string, withSignerIfPossible?: boo } export function useMulticallContract() { - return useContract(getMulticallAddress(), multiCallAbi, false) + const { chainId } = useActiveWeb3React() + return useContract(getMulticallAddress(chainId), multiCallAbi, false) } export function useZapContract(withSignerIfPossible = true) { - const { library, account } = useActiveWeb3React() - const signer = useMemo( - () => (withSignerIfPossible ? getProviderOrSigner(library, account) : null), - [withSignerIfPossible, library, account], - ) - return useMemo(() => getZapContract(signer), [signer]) + return useContract(getZapAddress(), zapAbi, withSignerIfPossible) } diff --git a/src/hooks/useGetBlockCountdown.ts b/src/hooks/useGetBlockCountdown.ts index ea071e19f..533a6be15 100644 --- a/src/hooks/useGetBlockCountdown.ts +++ b/src/hooks/useGetBlockCountdown.ts @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from 'react' import { BSC_BLOCK_TIME } from 'config' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' /** * Returns a countdown in seconds of a given block @@ -11,7 +11,7 @@ const useBlockCountdown = (blockNumber: number) => { useEffect(() => { const startCountdown = async () => { - const currentBlock = await simpleRpcProvider.getBlockNumber() + const currentBlock = await bscRpcProvider.getBlockNumber() if (blockNumber > currentBlock) { setSecondsRemaining((blockNumber - currentBlock) * BSC_BLOCK_TIME) diff --git a/src/hooks/useNftClaimStatusCheck.tsx b/src/hooks/useNftClaimStatusCheck.tsx index ab175ee1b..ae0dd2cc1 100644 --- a/src/hooks/useNftClaimStatusCheck.tsx +++ b/src/hooks/useNftClaimStatusCheck.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react' import { useModal } from '@pancakeswap/uikit' import { useWeb3React } from '@web3-react/core' import { getBunnySpecialXmasContract } from 'utils/contractHelpers' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import ClaimNftModal from 'components/ClaimNftModal/ClaimNftModal' import noop from 'lodash/noop' @@ -14,7 +14,7 @@ const useNftClaimStatusCheck = () => { useEffect(() => { const checkClaimStatus = async () => { try { - const canClaim = await getBunnySpecialXmasContract(simpleRpcProvider).canClaim(account) + const canClaim = await getBunnySpecialXmasContract(bscRpcProvider).canClaim(account) if (canClaim) { onPresentNftClaimModal() setHasDisplayedModal(true) diff --git a/src/hooks/useRefreshEffect.test.ts b/src/hooks/useRefreshEffect.test.ts index f5d2eb807..7f927b142 100644 --- a/src/hooks/useRefreshEffect.test.ts +++ b/src/hooks/useRefreshEffect.test.ts @@ -27,7 +27,7 @@ test('should refresh when deps changes', () => { test('should refresh when block changes', async () => { const callback = jest.fn() const { result, rerender } = renderHook(() => { - const { mutate, data } = useSWR([FAST_INTERVAL, 'blockNumber']) + const { mutate, data } = useSWR([FAST_INTERVAL, 'blockNumber', 56]) useFastRefreshEffect(callback, [callback]) return { mutate, data } }) @@ -48,7 +48,7 @@ test('should refresh when block changes', async () => { test('should get latest block number when block changes', async () => { const { result, rerender } = renderHook(() => { const [callbackResult, setCallbackResult] = useState() - const { mutate, data } = useSWR([SLOW_INTERVAL, 'blockNumber']) + const { mutate, data } = useSWR([SLOW_INTERVAL, 'blockNumber', 56]) useSlowRefreshEffect((b) => { setCallbackResult(b) }, []) diff --git a/src/hooks/useRefreshEffect.ts b/src/hooks/useRefreshEffect.ts index 2a9481b66..cfa7be3f5 100644 --- a/src/hooks/useRefreshEffect.ts +++ b/src/hooks/useRefreshEffect.ts @@ -1,20 +1,23 @@ import { FAST_INTERVAL, SLOW_INTERVAL } from 'config/constants' import { DependencyList, EffectCallback, useEffect } from 'react' import useSWR from 'swr' +import useActiveWeb3React from './useActiveWeb3React' type BlockEffectCallback = (blockNumber: number) => ReturnType const EMPTY_ARRAY = [] export function useFastRefreshEffect(effect: BlockEffectCallback, deps?: DependencyList) { - const { data = 0 } = useSWR([FAST_INTERVAL, 'blockNumber']) + const { chainId } = useActiveWeb3React() + const { data = 0 } = useSWR([FAST_INTERVAL, 'blockNumber', chainId]) // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(effect.bind(null, data), [data, ...(deps || EMPTY_ARRAY)]) } export function useSlowRefreshEffect(effect: BlockEffectCallback, deps?: DependencyList) { - const { data = 0 } = useSWR([SLOW_INTERVAL, 'blockNumber']) + const { chainId } = useActiveWeb3React() + const { data = 0 } = useSWR([SLOW_INTERVAL, 'blockNumber', chainId]) // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(effect.bind(null, data), [data, ...(deps || EMPTY_ARRAY)]) diff --git a/src/hooks/useSubgraphHealth.ts b/src/hooks/useSubgraphHealth.ts index 90f9e0299..ec1c5042e 100644 --- a/src/hooks/useSubgraphHealth.ts +++ b/src/hooks/useSubgraphHealth.ts @@ -1,6 +1,6 @@ import { useState } from 'react' import { request, gql } from 'graphql-request' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import { GRAPH_HEALTH } from 'config/constants/endpoints' import { useSlowRefreshEffect } from './useRefreshEffect' @@ -55,7 +55,7 @@ const useSubgraphHealth = (subgraphName: string) => { } `, ), - currentBlockNumber ? Promise.resolve(currentBlockNumber) : simpleRpcProvider.getBlockNumber(), + currentBlockNumber ? Promise.resolve(currentBlockNumber) : bscRpcProvider.getBlockNumber(), ]) const isHealthy = indexingStatusForCurrentVersion.health === 'healthy' diff --git a/src/hooks/useTokenBalance.ts b/src/hooks/useTokenBalance.ts index 91b8fcc6f..e10ad7ec4 100644 --- a/src/hooks/useTokenBalance.ts +++ b/src/hooks/useTokenBalance.ts @@ -1,12 +1,12 @@ import { useWeb3React } from '@web3-react/core' import BigNumber from 'bignumber.js' -import tokens from 'config/constants/tokens' +import { CAKE } from 'config/constants/tokens' import { FAST_INTERVAL } from 'config/constants' import { BigNumber as EthersBigNumber } from '@ethersproject/bignumber' import { Zero } from '@ethersproject/constants' import useSWR from 'swr' import { BIG_ZERO } from 'utils/bigNumber' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import { useTokenContract } from './useContract' import { useSWRContract } from './useSWRContract' @@ -37,14 +37,15 @@ const useTokenBalance = (tokenAddress: string) => { export const useGetBnbBalance = () => { const { account } = useWeb3React() const { status, data, mutate } = useSWR([account, 'bnbBalance'], async () => { - return simpleRpcProvider.getBalance(account) + return bscRpcProvider.getBalance(account) }) return { balance: data || Zero, fetchStatus: status, refresh: mutate } } export const useGetCakeBalance = () => { - const { balance, fetchStatus } = useTokenBalance(tokens.cake.address) + const { chainId } = useWeb3React() + const { balance, fetchStatus } = useTokenBalance(CAKE[chainId]?.address) // TODO: Remove ethers conversion once useTokenBalance is converted to ethers.BigNumber return { balance: EthersBigNumber.from(balance.toString()), fetchStatus } diff --git a/src/hooks/useWrapCallback.ts b/src/hooks/useWrapCallback.ts index 551e8d1ac..d655f33b1 100644 --- a/src/hooks/useWrapCallback.ts +++ b/src/hooks/useWrapCallback.ts @@ -1,4 +1,4 @@ -import { Currency, currencyEquals, ETHER, WETH } from '@pancakeswap/sdk' +import { Currency, currencyEquals, ETHER, WNATIVE } from '@pancakeswap/sdk' import { useMemo } from 'react' import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useTranslation } from 'contexts/Localization' @@ -40,7 +40,7 @@ export default function useWrapCallback( const sufficientBalance = inputAmount && balance && !balance.lessThan(inputAmount) - if (inputCurrency === ETHER && currencyEquals(WETH[chainId], outputCurrency)) { + if (inputCurrency === ETHER && currencyEquals(WNATIVE[chainId], outputCurrency)) { return { wrapType: WrapType.WRAP, execute: @@ -62,7 +62,7 @@ export default function useWrapCallback( inputError: sufficientBalance ? undefined : t('Insufficient BNB balance'), } } - if (currencyEquals(WETH[chainId], inputCurrency) && outputCurrency === ETHER) { + if (currencyEquals(WNATIVE[chainId], inputCurrency) && outputCurrency === ETHER) { return { wrapType: WrapType.UNWRAP, execute: diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index a4d218296..ff617f6d9 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,7 +1,6 @@ /* eslint-disable jsx-a11y/iframe-has-title */ import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document' import { ServerStyleSheet } from 'styled-components' -import { nodes } from 'utils/getRpcUrl' class MyDocument extends Document { static async getInitialProps(ctx: DocumentContext) { @@ -34,9 +33,6 @@ class MyDocument extends Document { return ( - {nodes.map((node) => ( - - ))} {process.env.NEXT_PUBLIC_NODE_PRODUCTION && ( )} diff --git a/src/state/block/hooks.ts b/src/state/block/hooks.ts index 92946f3e9..330b0168f 100644 --- a/src/state/block/hooks.ts +++ b/src/state/block/hooks.ts @@ -1,19 +1,20 @@ import { FAST_INTERVAL, SLOW_INTERVAL } from 'config/constants' import useSWR, { useSWRConfig } from 'swr' -import { simpleRpcProvider } from 'utils/providers' import useSWRImmutable from 'swr/immutable' +import useActiveWeb3React from 'hooks/useActiveWeb3React' const REFRESH_BLOCK_INTERVAL = 6000 export const usePollBlockNumber = () => { const { cache, mutate } = useSWRConfig() + const { library, chainId } = useActiveWeb3React() const { data } = useSWR( - 'blockNumber', + `blockNumber-${chainId}`, async () => { - const blockNumber = await simpleRpcProvider.getBlockNumber() - if (!cache.get('initialBlockNumber')) { - mutate('initialBlockNumber', blockNumber) + const blockNumber = await library.getBlockNumber() + if (!cache.get(`initialBlockNumber-${chainId}`)) { + mutate(`initialBlockNumber-${chainId}`, blockNumber) } return blockNumber }, @@ -23,7 +24,7 @@ export const usePollBlockNumber = () => { ) useSWR( - [FAST_INTERVAL, 'blockNumber'], + [FAST_INTERVAL, 'blockNumber', chainId], async () => { return data }, @@ -33,7 +34,7 @@ export const usePollBlockNumber = () => { ) useSWR( - [SLOW_INTERVAL, 'blockNumber'], + [SLOW_INTERVAL, 'blockNumber', chainId], async () => { return data }, @@ -44,11 +45,13 @@ export const usePollBlockNumber = () => { } export const useCurrentBlock = (): number => { - const { data: currentBlock = 0 } = useSWRImmutable('blockNumber') + const { chainId } = useActiveWeb3React() + const { data: currentBlock = 0 } = useSWRImmutable(`blockNumber-${chainId}`) return currentBlock } export const useInitialBlock = (): number => { - const { data: initialBlock = 0 } = useSWRImmutable('initialBlockNumber') + const { chainId } = useActiveWeb3React() + const { data: initialBlock = 0 } = useSWRImmutable(`initialBlockNumber-${chainId}`) return initialBlock } diff --git a/src/state/farms/getFarmsPrices.ts b/src/state/farms/getFarmsPrices.ts index 471f538f0..61f04ce20 100644 --- a/src/state/farms/getFarmsPrices.ts +++ b/src/state/farms/getFarmsPrices.ts @@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js' import { BIG_ONE, BIG_ZERO } from 'utils/bigNumber' import { filterFarmsByQuoteToken } from 'utils/farmsPriceHelpers' import { SerializedFarm } from 'state/types' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' const getFarmFromTokenSymbol = ( farms: SerializedFarm[], @@ -21,11 +21,11 @@ const getFarmBaseTokenPrice = ( ): BigNumber => { const hasTokenPriceVsQuote = Boolean(farm.tokenPriceVsQuote) - if (farm.quoteToken.symbol === tokens.busd.symbol) { + if (farm.quoteToken.symbol === bscTokens.busd.symbol) { return hasTokenPriceVsQuote ? new BigNumber(farm.tokenPriceVsQuote) : BIG_ZERO } - if (farm.quoteToken.symbol === tokens.wbnb.symbol) { + if (farm.quoteToken.symbol === bscTokens.wbnb.symbol) { return hasTokenPriceVsQuote ? bnbPriceBusd.times(farm.tokenPriceVsQuote) : BIG_ZERO } @@ -39,14 +39,14 @@ const getFarmBaseTokenPrice = ( // If the farm's quote token isn't BUSD or WBNB, we then use the quote token, of the original farm's quote token // i.e. for farm PNT - pBTC we use the pBTC farm's quote token - BNB, (pBTC - BNB) // from the BNB - pBTC price, we can calculate the PNT - BUSD price - if (quoteTokenFarm.quoteToken.symbol === tokens.wbnb.symbol) { + if (quoteTokenFarm.quoteToken.symbol === bscTokens.wbnb.symbol) { const quoteTokenInBusd = bnbPriceBusd.times(quoteTokenFarm.tokenPriceVsQuote) return hasTokenPriceVsQuote && quoteTokenInBusd ? new BigNumber(farm.tokenPriceVsQuote).times(quoteTokenInBusd) : BIG_ZERO } - if (quoteTokenFarm.quoteToken.symbol === tokens.busd.symbol) { + if (quoteTokenFarm.quoteToken.symbol === bscTokens.busd.symbol) { const quoteTokenInBusd = quoteTokenFarm.tokenPriceVsQuote return hasTokenPriceVsQuote && quoteTokenInBusd ? new BigNumber(farm.tokenPriceVsQuote).times(quoteTokenInBusd) diff --git a/src/state/farms/hooks.ts b/src/state/farms/hooks.ts index 4781fe0a3..7bc04cdf1 100644 --- a/src/state/farms/hooks.ts +++ b/src/state/farms/hooks.ts @@ -1,8 +1,6 @@ -import { ChainId } from '@pancakeswap/sdk' import { useWeb3React } from '@web3-react/core' import BigNumber from 'bignumber.js' import { farmsConfig, SLOW_INTERVAL } from 'config/constants' -import { CHAIN_ID } from 'config/constants/networks' import { useFastRefreshEffect } from 'hooks/useRefreshEffect' import useSWRImmutable from 'swr/immutable' import { useMemo } from 'react' @@ -52,12 +50,18 @@ export const usePollFarmsWithUserData = () => { * 2 = CAKE-BNB LP * 3 = BUSD-BNB LP */ -const coreFarmPIDs = CHAIN_ID === String(ChainId.MAINNET) ? [2, 3] : [1, 2] +const coreFarmPIDs = { + 56: [2, 3], + 97: [1, 2], +} + export const usePollCoreFarmData = () => { const dispatch = useAppDispatch() + // TODO: multi + // const { chainId } = useActiveWeb3React() useFastRefreshEffect(() => { - dispatch(fetchFarmsPublicDataAsync(coreFarmPIDs)) + dispatch(fetchFarmsPublicDataAsync(coreFarmPIDs[56])) }, [dispatch]) } diff --git a/src/state/farmsV1/getFarmsPrices.ts b/src/state/farmsV1/getFarmsPrices.ts index e67c8cead..742199790 100644 --- a/src/state/farmsV1/getFarmsPrices.ts +++ b/src/state/farmsV1/getFarmsPrices.ts @@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js' import { BIG_ONE, BIG_ZERO } from 'utils/bigNumber' import { filterFarmsByQuoteToken } from 'utils/farmsPriceHelpers' import { SerializedFarm } from 'state/types' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' const getFarmFromTokenSymbol = ( farms: SerializedFarm[], @@ -21,11 +21,11 @@ const getFarmBaseTokenPrice = ( ): BigNumber => { const hasTokenPriceVsQuote = Boolean(farm.tokenPriceVsQuote) - if (farm.quoteToken.symbol === tokens.busd.symbol) { + if (farm.quoteToken.symbol === bscTokens.busd.symbol) { return hasTokenPriceVsQuote ? new BigNumber(farm.tokenPriceVsQuote) : BIG_ZERO } - if (farm.quoteToken.symbol === tokens.wbnb.symbol) { + if (farm.quoteToken.symbol === bscTokens.wbnb.symbol) { return hasTokenPriceVsQuote ? bnbPriceBusd.times(farm.tokenPriceVsQuote) : BIG_ZERO } @@ -39,14 +39,14 @@ const getFarmBaseTokenPrice = ( // If the farm's quote token isn't BUSD or WBNB, we then use the quote token, of the original farm's quote token // i.e. for farm PNT - pBTC we use the pBTC farm's quote token - BNB, (pBTC - BNB) // from the BNB - pBTC price, we can calculate the PNT - BUSD price - if (quoteTokenFarm.quoteToken.symbol === tokens.wbnb.symbol) { + if (quoteTokenFarm.quoteToken.symbol === bscTokens.wbnb.symbol) { const quoteTokenInBusd = bnbPriceBusd.times(quoteTokenFarm.tokenPriceVsQuote) return hasTokenPriceVsQuote && quoteTokenInBusd ? new BigNumber(farm.tokenPriceVsQuote).times(quoteTokenInBusd) : BIG_ZERO } - if (quoteTokenFarm.quoteToken.symbol === tokens.busd.symbol) { + if (quoteTokenFarm.quoteToken.symbol === bscTokens.busd.symbol) { const quoteTokenInBusd = quoteTokenFarm.tokenPriceVsQuote return hasTokenPriceVsQuote && quoteTokenInBusd ? new BigNumber(farm.tokenPriceVsQuote).times(quoteTokenInBusd) diff --git a/src/state/lists/hooks.ts b/src/state/lists/hooks.ts index 9e5d02dc4..4294a457c 100644 --- a/src/state/lists/hooks.ts +++ b/src/state/lists/hooks.ts @@ -165,8 +165,8 @@ export function useAllLists(): { function combineMaps(map1: TokenAddressMap, map2: TokenAddressMap): TokenAddressMap { return { - [ChainId.MAINNET]: { ...map1[ChainId.MAINNET], ...map2[ChainId.MAINNET] }, - [ChainId.TESTNET]: { ...map1[ChainId.TESTNET], ...map2[ChainId.TESTNET] }, + [ChainId.BSC]: { ...map1[ChainId.BSC], ...map2[ChainId.BSC] }, + [ChainId.BSC_TESTNET]: { ...map1[ChainId.BSC_TESTNET], ...map2[ChainId.BSC_TESTNET] }, } } diff --git a/src/state/multicall/hooks.ts b/src/state/multicall/hooks.ts index f584effff..8d0230fa0 100644 --- a/src/state/multicall/hooks.ts +++ b/src/state/multicall/hooks.ts @@ -168,6 +168,7 @@ export function useSingleContractMultipleData( callInputs: OptionalMethodInputs[], options?: ListenerOptions, ): CallState[] { + const { chainId } = useActiveWeb3React() const fragment = useMemo(() => contract?.interface?.getFunction(methodName), [contract, methodName]) const calls = useMemo( @@ -188,9 +189,9 @@ export function useSingleContractMultipleData( const { cache } = useSWRConfig() return useMemo(() => { - const currentBlockNumber = cache.get('blockNumber') + const currentBlockNumber = cache.get(`blockNumber-${chainId}`) return results.map((result) => toCallState(result, contract?.interface, fragment, currentBlockNumber)) - }, [fragment, contract, results, cache]) + }, [cache, chainId, results, contract?.interface, fragment]) } export function useMultipleContractSingleData( @@ -225,13 +226,14 @@ export function useMultipleContractSingleData( ) const results = useCallsData(calls, options) + const { chainId } = useActiveWeb3React() const { cache } = useSWRConfig() return useMemo(() => { - const currentBlockNumber = cache.get('blockNumber') + const currentBlockNumber = cache.get(`blockNumber-${chainId}`) return results.map((result) => toCallState(result, contractInterface, fragment, currentBlockNumber)) - }, [fragment, results, contractInterface, cache]) + }, [cache, chainId, results, contractInterface, fragment]) } export function useSingleCallResult( @@ -255,9 +257,10 @@ export function useSingleCallResult( const result = useCallsData(calls, options)[0] const { cache } = useSWRConfig() + const { chainId } = useActiveWeb3React() return useMemo(() => { - const currentBlockNumber = cache.get('blockNumber') + const currentBlockNumber = cache.get(`blockNumber-${chainId}`) return toCallState(result, contract?.interface, fragment, currentBlockNumber) - }, [cache, result, contract?.interface, fragment]) + }, [cache, chainId, result, contract?.interface, fragment]) } diff --git a/src/state/pools/fetchPoolsUser.ts b/src/state/pools/fetchPoolsUser.ts index 40282477a..7dffc109e 100644 --- a/src/state/pools/fetchPoolsUser.ts +++ b/src/state/pools/fetchPoolsUser.ts @@ -3,7 +3,7 @@ import sousChefABI from 'config/abi/sousChef.json' import erc20ABI from 'config/abi/erc20.json' import multicall from 'utils/multicall' import { getAddress } from 'utils/addressHelpers' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import BigNumber from 'bignumber.js' import uniq from 'lodash/uniq' @@ -48,7 +48,7 @@ export const fetchUserBalances = async (account) => { ) // BNB pools - const bnbBalance = await simpleRpcProvider.getBalance(account) + const bnbBalance = await bscRpcProvider.getBalance(account) const bnbBalances = bnbPools.reduce( (acc, pool) => ({ ...acc, [pool.sousId]: new BigNumber(bnbBalance.toString()).toJSON() }), {}, diff --git a/src/state/pools/index.ts b/src/state/pools/index.ts index dae75eba1..dc87fe00a 100644 --- a/src/state/pools/index.ts +++ b/src/state/pools/index.ts @@ -16,9 +16,9 @@ import { BIG_ZERO } from 'utils/bigNumber' import cakeAbi from 'config/abi/cake.json' import { getCakeVaultAddress, getCakeFlexibleSideVaultAddress } from 'utils/addressHelpers' import { multicallv2 } from 'utils/multicall' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { getBalanceNumber } from 'utils/formatBalance' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import priceHelperLpsConfig from 'config/constants/priceHelperLps' import fetchFarms from '../farms/fetchFarms' import getFarmsPrices from '../farms/getFarmsPrices' @@ -108,12 +108,12 @@ export const fetchCakePoolPublicDataAsync = () => async (dispatch, getState) => export const fetchCakePoolUserDataAsync = (account: string) => async (dispatch) => { const allowanceCall = { - address: tokens.cake.address, + address: bscTokens.cake.address, name: 'allowance', params: [account, cakeVaultAddress], } const balanceOfCall = { - address: tokens.cake.address, + address: bscTokens.cake.address, name: 'balanceOf', params: [account], } @@ -137,7 +137,7 @@ export const fetchPoolsPublicDataAsync = (currentBlockNumber: number) => async ( fetchPoolsBlockLimits(), fetchPoolsTotalStaking(), fetchPoolsProfileRequirement(), - currentBlockNumber ? Promise.resolve(currentBlockNumber) : simpleRpcProvider.getBlockNumber(), + currentBlockNumber ? Promise.resolve(currentBlockNumber) : bscRpcProvider.getBlockNumber(), ]) const activePriceHelperLpsConfig = priceHelperLpsConfig.filter((priceHelperLpConfig) => { diff --git a/src/state/swap/hooks.test.ts b/src/state/swap/hooks.test.ts index b90d43c5c..af66c7584 100644 --- a/src/state/swap/hooks.test.ts +++ b/src/state/swap/hooks.test.ts @@ -98,7 +98,9 @@ describe('hooks', () => { var mockUseActiveWeb3React: jest.Mock jest.mock('../../hooks/useActiveWeb3React', () => { - mockUseActiveWeb3React = jest.fn().mockReturnValue({}) + mockUseActiveWeb3React = jest.fn().mockReturnValue({ + chainId: 56, + }) return { __esModule: true, default: mockUseActiveWeb3React, diff --git a/src/state/swap/hooks.ts b/src/state/swap/hooks.ts index 948338c3e..ad0afb06c 100644 --- a/src/state/swap/hooks.ts +++ b/src/state/swap/hooks.ts @@ -1,4 +1,4 @@ -import { Currency, CurrencyAmount, Trade } from '@pancakeswap/sdk' +import { ChainId, Currency, CurrencyAmount, Pair, Trade } from '@pancakeswap/sdk' import { useWeb3React } from '@web3-react/core' import { ParsedUrlQuery } from 'querystring' import { useEffect, useMemo, useState } from 'react' @@ -397,9 +397,9 @@ export const useFetchPairPrices = ({ return { pairPrices, pairId } } -export const useLPApr = (pair) => { +export const useLPApr = (pair?: Pair) => { const { data: poolData } = useSWRImmutable( - pair ? ['LP7dApr', pair.liquidityToken.address] : null, + pair && pair.chainId === ChainId.BSC ? ['LP7dApr', pair.liquidityToken.address] : null, async () => { const timestampsArray = getDeltaTimestamps() const blocks = await getBlocksFromTimestamps(timestampsArray, 'desc', 1000) diff --git a/src/state/transactions/reducer.test.ts b/src/state/transactions/reducer.test.ts index e727d4662..bc3ad310c 100644 --- a/src/state/transactions/reducer.test.ts +++ b/src/state/transactions/reducer.test.ts @@ -15,7 +15,7 @@ describe('transaction reducer', () => { const beforeTime = new Date().getTime() store.dispatch( addTransaction({ - chainId: ChainId.MAINNET, + chainId: ChainId.BSC, summary: 'hello world', hash: '0x0', approval: { tokenAddress: 'abc', spender: 'def' }, @@ -23,9 +23,9 @@ describe('transaction reducer', () => { }), ) const txs = store.getState() - expect(txs[ChainId.MAINNET]).toBeTruthy() - expect(txs[ChainId.MAINNET]?.['0x0']).toBeTruthy() - const tx = txs[ChainId.MAINNET]?.['0x0'] + expect(txs[ChainId.BSC]).toBeTruthy() + expect(txs[ChainId.BSC]?.['0x0']).toBeTruthy() + const tx = txs[ChainId.BSC]?.['0x0'] expect(tx).toBeTruthy() expect(tx?.hash).toEqual('0x0') expect(tx?.summary).toEqual('hello world') @@ -39,7 +39,7 @@ describe('transaction reducer', () => { it('no op if not valid transaction', () => { store.dispatch( finalizeTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, hash: '0x0', receipt: { status: 1, @@ -59,7 +59,7 @@ describe('transaction reducer', () => { store.dispatch( addTransaction({ hash: '0x0', - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, approval: { spender: '0x0', tokenAddress: '0x0' }, summary: 'hello world', from: '0x0', @@ -68,7 +68,7 @@ describe('transaction reducer', () => { const beforeTime = new Date().getTime() store.dispatch( finalizeTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, hash: '0x0', receipt: { status: 1, @@ -82,7 +82,7 @@ describe('transaction reducer', () => { }, }), ) - const tx = store.getState()[ChainId.TESTNET]?.['0x0'] + const tx = store.getState()[ChainId.BSC_TESTNET]?.['0x0'] expect(tx?.summary).toEqual('hello world') expect(tx?.confirmedTime).toBeGreaterThanOrEqual(beforeTime) expect(tx?.receipt).toEqual({ @@ -102,7 +102,7 @@ describe('transaction reducer', () => { it('no op if not valid transaction', () => { store.dispatch( checkedTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, hash: '0x0', blockNumber: 1, }), @@ -113,7 +113,7 @@ describe('transaction reducer', () => { store.dispatch( addTransaction({ hash: '0x0', - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, approval: { spender: '0x0', tokenAddress: '0x0' }, summary: 'hello world', from: '0x0', @@ -121,19 +121,19 @@ describe('transaction reducer', () => { ) store.dispatch( checkedTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, hash: '0x0', blockNumber: 1, }), ) - const tx = store.getState()[ChainId.TESTNET]?.['0x0'] + const tx = store.getState()[ChainId.BSC_TESTNET]?.['0x0'] expect(tx?.lastCheckedBlockNumber).toEqual(1) }) it('never decreases', () => { store.dispatch( addTransaction({ hash: '0x0', - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, approval: { spender: '0x0', tokenAddress: '0x0' }, summary: 'hello world', from: '0x0', @@ -141,19 +141,19 @@ describe('transaction reducer', () => { ) store.dispatch( checkedTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, hash: '0x0', blockNumber: 3, }), ) store.dispatch( checkedTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, hash: '0x0', blockNumber: 1, }), ) - const tx = store.getState()[ChainId.TESTNET]?.['0x0'] + const tx = store.getState()[ChainId.BSC_TESTNET]?.['0x0'] expect(tx?.lastCheckedBlockNumber).toEqual(3) }) }) @@ -162,7 +162,7 @@ describe('transaction reducer', () => { it('removes all transactions for the chain', () => { store.dispatch( addTransaction({ - chainId: ChainId.MAINNET, + chainId: ChainId.BSC, summary: 'hello world', hash: '0x0', approval: { tokenAddress: 'abc', spender: 'def' }, @@ -171,7 +171,7 @@ describe('transaction reducer', () => { ) store.dispatch( addTransaction({ - chainId: ChainId.TESTNET, + chainId: ChainId.BSC_TESTNET, summary: 'hello world', hash: '0x1', approval: { tokenAddress: 'abc', spender: 'def' }, @@ -179,14 +179,14 @@ describe('transaction reducer', () => { }), ) expect(Object.keys(store.getState())).toHaveLength(2) - expect(Object.keys(store.getState())).toEqual([String(ChainId.MAINNET), String(ChainId.TESTNET)]) - expect(Object.keys(store.getState()[ChainId.MAINNET] ?? {})).toEqual(['0x0']) - expect(Object.keys(store.getState()[ChainId.TESTNET] ?? {})).toEqual(['0x1']) - store.dispatch(clearAllTransactions({ chainId: ChainId.MAINNET })) + expect(Object.keys(store.getState())).toEqual([String(ChainId.BSC), String(ChainId.BSC_TESTNET)]) + expect(Object.keys(store.getState()[ChainId.BSC] ?? {})).toEqual(['0x0']) + expect(Object.keys(store.getState()[ChainId.BSC_TESTNET] ?? {})).toEqual(['0x1']) + store.dispatch(clearAllTransactions({ chainId: ChainId.BSC })) expect(Object.keys(store.getState())).toHaveLength(2) - expect(Object.keys(store.getState())).toEqual([String(ChainId.MAINNET), String(ChainId.TESTNET)]) - expect(Object.keys(store.getState()[ChainId.MAINNET] ?? {})).toEqual([]) - expect(Object.keys(store.getState()[ChainId.TESTNET] ?? {})).toEqual(['0x1']) + expect(Object.keys(store.getState())).toEqual([String(ChainId.BSC), String(ChainId.BSC_TESTNET)]) + expect(Object.keys(store.getState()[ChainId.BSC] ?? {})).toEqual([]) + expect(Object.keys(store.getState()[ChainId.BSC_TESTNET] ?? {})).toEqual(['0x1']) }) }) }) diff --git a/src/state/types.ts b/src/state/types.ts index e4b0b0edb..7800ba673 100644 --- a/src/state/types.ts +++ b/src/state/types.ts @@ -49,8 +49,8 @@ export interface TagInfo extends TagDetails { * An empty result, useful as a default. */ export const EMPTY_LIST: TokenAddressMap = { - [ChainId.MAINNET]: {}, - [ChainId.TESTNET]: {}, + [ChainId.BSC]: {}, + [ChainId.BSC_TESTNET]: {}, } export enum GAS_PRICE { diff --git a/src/state/user/hooks/index.tsx b/src/state/user/hooks/index.tsx index 7c5d97abb..e1b0e7934 100644 --- a/src/state/user/hooks/index.tsx +++ b/src/state/user/hooks/index.tsx @@ -4,7 +4,6 @@ import flatMap from 'lodash/flatMap' import farms from 'config/constants/farms' import { useCallback, useMemo } from 'react' import { useSelector } from 'react-redux' -import { CHAIN_ID } from 'config/constants/networks' import { BASES_TO_TRACK_LIQUIDITY_FOR, PINNED_PAIRS } from 'config/constants' import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useOfficialsAndUserAddedTokens } from 'hooks/Tokens' @@ -402,9 +401,9 @@ export function useRemoveUserAddedToken(): (chainId: number, address: string) => } export function useGasPrice(): string { - const chainId = CHAIN_ID + const { chainId } = useActiveWeb3React() const userGas = useSelector((state) => state.user.gasPrice) - return chainId === ChainId.MAINNET.toString() ? userGas : GAS_PRICE_GWEI.testnet + return chainId === ChainId.BSC ? userGas : GAS_PRICE_GWEI.testnet } export function useGasPriceManager(): [string, (userGasPrice: string) => void] { diff --git a/src/state/user/hooks/useUserAddedTokens.ts b/src/state/user/hooks/useUserAddedTokens.ts index c6e74a1e6..80d520e7a 100644 --- a/src/state/user/hooks/useUserAddedTokens.ts +++ b/src/state/user/hooks/useUserAddedTokens.ts @@ -1,15 +1,17 @@ -import { ChainId, Token } from '@pancakeswap/sdk' +import { Token } from '@pancakeswap/sdk' import { createSelector } from '@reduxjs/toolkit' -import { CHAIN_ID } from 'config/constants/networks' +import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useSelector } from 'react-redux' import { AppState } from '../../index' import { deserializeToken } from './helpers' const selectUserTokens = ({ user: { tokens } }: AppState) => tokens -export const userAddedTokenSelector = createSelector(selectUserTokens, (serializedTokensMap) => - Object.values(serializedTokensMap?.[CHAIN_ID as unknown as ChainId] ?? {}).map(deserializeToken), -) +export const userAddedTokenSelector = (chainId: number) => + createSelector(selectUserTokens, (serializedTokensMap) => + Object.values(serializedTokensMap?.[chainId] ?? {}).map(deserializeToken), + ) export default function useUserAddedTokens(): Token[] { - return useSelector(userAddedTokenSelector) + const { chainId } = useActiveWeb3React() + return useSelector(userAddedTokenSelector(chainId)) } diff --git a/src/utils/addressHelpers.ts b/src/utils/addressHelpers.ts index faf0cecdc..8379dbb5f 100644 --- a/src/utils/addressHelpers.ts +++ b/src/utils/addressHelpers.ts @@ -3,9 +3,8 @@ import addresses from 'config/constants/contracts' import { Address } from 'config/constants/types' import { VaultKey } from 'state/types' -export const getAddress = (address: Address): string => { - const chainId = process.env.NEXT_PUBLIC_CHAIN_ID - return address[chainId] ? address[chainId] : address[ChainId.MAINNET] +export const getAddress = (address: Address, chainId?: number): string => { + return address[chainId] ? address[chainId] : address[ChainId.BSC] } export const getMasterChefAddress = () => { @@ -14,8 +13,8 @@ export const getMasterChefAddress = () => { export const getMasterChefV1Address = () => { return getAddress(addresses.masterChefV1) } -export const getMulticallAddress = () => { - return getAddress(addresses.multiCall) +export const getMulticallAddress = (chainId?: number) => { + return getAddress(addresses.multiCall, chainId) } export const getLotteryV2Address = () => { return getAddress(addresses.lotteryV2) @@ -93,9 +92,7 @@ export const getFarmAuctionAddress = () => { export const getAnniversaryAchievement = () => { return getAddress(addresses.AnniversaryAchievement) } -export const getGalaxyNFTClaimingAddress = () => { - return getAddress(addresses.galaxyNftClaiming) -} + export const getNftMarketAddress = () => { return getAddress(addresses.nftMarket) } diff --git a/src/utils/calls/pools.ts b/src/utils/calls/pools.ts index 0bf559c08..30faf53ad 100644 --- a/src/utils/calls/pools.ts +++ b/src/utils/calls/pools.ts @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js' import poolsConfig from 'config/constants/pools' import sousChefV2 from 'config/abi/sousChefV2.json' import multicall from '../multicall' -import { simpleRpcProvider } from '../providers' +import { bscRpcProvider } from '../providers' import { getAddress } from '../addressHelpers' /** @@ -13,13 +13,13 @@ export const getActivePools = async (block?: number) => { const eligiblePools = poolsConfig .filter((pool) => pool.sousId !== 0) .filter((pool) => pool.isFinished === false || pool.isFinished === undefined) - const blockNumber = block || (await simpleRpcProvider.getBlockNumber()) + const blockNumber = block || (await bscRpcProvider.getBlockNumber()) const startBlockCalls = eligiblePools.map(({ contractAddress }) => ({ - address: getAddress(contractAddress), + address: getAddress(contractAddress, 56), name: 'startBlock', })) const endBlockCalls = eligiblePools.map(({ contractAddress }) => ({ - address: getAddress(contractAddress), + address: getAddress(contractAddress, 56), name: 'bonusEndBlock', })) const [startBlocks, endBlocks] = await Promise.all([ diff --git a/src/utils/contractHelpers.ts b/src/utils/contractHelpers.ts index 7bfebb189..ce35c18ca 100644 --- a/src/utils/contractHelpers.ts +++ b/src/utils/contractHelpers.ts @@ -1,10 +1,10 @@ import type { Signer } from '@ethersproject/abstract-signer' import type { Provider } from '@ethersproject/providers' import { Contract } from '@ethersproject/contracts' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import poolsConfig from 'config/constants/pools' import { PoolCategory } from 'config/constants/types' -import tokens from 'config/constants/tokens' +import { CAKE } from 'config/constants/tokens' // Addresses import { @@ -35,7 +35,6 @@ import { getTradingCompetitionAddressMoD, getBunnySpecialXmasAddress, getICakeAddress, - getGalaxyNFTClaimingAddress, getZapAddress, getCakeFlexibleSideVaultAddress, getPredictionsV1Address, @@ -77,7 +76,6 @@ import bunnySpecialLotteryAbi from 'config/abi/bunnySpecialLottery.json' import bunnySpecialXmasAbi from 'config/abi/bunnySpecialXmas.json' import farmAuctionAbi from 'config/abi/farmAuction.json' import anniversaryAchievementAbi from 'config/abi/anniversaryAchievement.json' -import galaxyNFTClaimingAbi from 'config/abi/galaxyNFTClaiming.json' import nftMarketAbi from 'config/abi/nftMarket.json' import nftSaleAbi from 'config/abi/nftSale.json' import pancakeSquadAbi from 'config/abi/pancakeSquad.json' @@ -116,7 +114,6 @@ import type { BunnySpecialCakeVault, BunnySpecialPrediction, BunnySpecialLottery, - GalaxyNFTClaiming, NftMarket, NftSale, PancakeSquad, @@ -130,9 +127,10 @@ import type { Zap, PredictionsV1, } from 'config/abi/types' +import { ChainId } from '@pancakeswap/sdk' export const getContract = (abi: any, address: string, signer?: Signer | Provider) => { - const signerOrProvider = signer ?? simpleRpcProvider + const signerOrProvider = signer ?? bscRpcProvider return new Contract(address, abi, signerOrProvider) } @@ -167,8 +165,8 @@ export const getSouschefV2Contract = (id: number, signer?: Signer | Provider) => export const getPointCenterIfoContract = (signer?: Signer | Provider) => { return getContract(pointCenterIfo, getPointCenterIfoAddress(), signer) as PointCenterIfo } -export const getCakeContract = (signer?: Signer | Provider) => { - return getContract(cakeAbi, tokens.cake.address, signer) as Cake +export const getCakeContract = (signer?: Signer | Provider, chainId?: number) => { + return getContract(cakeAbi, chainId ? CAKE[chainId].address : CAKE[ChainId.BSC].address, signer) as Cake } export const getProfileContract = (signer?: Signer | Provider) => { return getContract(profileABI, getPancakeProfileAddress(), signer) as PancakeProfile @@ -244,7 +242,7 @@ export const getChainlinkOracleContract = (address: string, signer?: Signer | Pr return getContract(chainlinkOracleAbi, address, signer) as ChainlinkOracle } export const getMulticallContract = () => { - return getContract(MultiCallAbi, getMulticallAddress(), simpleRpcProvider) as Multicall + return getContract(MultiCallAbi, getMulticallAddress(), bscRpcProvider) as Multicall } export const getBunnySpecialCakeVaultContract = (signer?: Signer | Provider) => { return getContract(bunnySpecialCakeVaultAbi, getBunnySpecialCakeVaultAddress(), signer) as BunnySpecialCakeVault @@ -264,9 +262,6 @@ export const getFarmAuctionContract = (signer?: Signer | Provider) => { export const getAnniversaryAchievementContract = (signer?: Signer | Provider) => { return getContract(anniversaryAchievementAbi, getAnniversaryAchievement(), signer) as AnniversaryAchievement } -export const getGalaxyNTFClaimingContract = (signer?: Signer | Provider) => { - return getContract(galaxyNFTClaimingAbi, getGalaxyNFTClaimingAddress(), signer) as GalaxyNFTClaiming -} export const getNftMarketContract = (signer?: Signer | Provider) => { return getContract(nftMarketAbi, getNftMarketAddress(), signer) as NftMarket diff --git a/src/utils/exchange.ts b/src/utils/exchange.ts index e7055e65e..ea318eb72 100644 --- a/src/utils/exchange.ts +++ b/src/utils/exchange.ts @@ -1,7 +1,6 @@ import { Web3Provider } from '@ethersproject/providers' import IPancakeRouter02ABI from 'config/abi/IPancakeRouter02.json' import { IPancakeRouter02 } from 'config/abi/types/IPancakeRouter02' -import { CHAIN_ID } from 'config/constants/networks' import { JSBI, Percent, CurrencyAmount, Trade, Fraction, TokenAmount } from '@pancakeswap/sdk' import { ROUTER_ADDRESS, @@ -32,9 +31,9 @@ export function calculateSlippageAmount(value: CurrencyAmount, slippage: number) } // account is optional -export function getRouterContract(_: number, library: Web3Provider, account?: string) { +export function getRouterContract(chainId: number, library: Web3Provider, account?: string) { return getContract( - ROUTER_ADDRESS[CHAIN_ID], + ROUTER_ADDRESS[chainId], IPancakeRouter02ABI, getProviderOrSigner(library, account), ) as IPancakeRouter02 diff --git a/src/utils/getGasPrice.ts b/src/utils/getGasPrice.ts index 28a2f657a..67e48358a 100644 --- a/src/utils/getGasPrice.ts +++ b/src/utils/getGasPrice.ts @@ -10,7 +10,7 @@ const getGasPrice = (): string => { const chainId = CHAIN_ID const state = store.getState() const userGas = state.user.gasPrice || GAS_PRICE_GWEI.default - return chainId === ChainId.MAINNET.toString() ? userGas : GAS_PRICE_GWEI.testnet + return chainId === ChainId.BSC.toString() ? userGas : GAS_PRICE_GWEI.testnet } export default getGasPrice diff --git a/src/utils/getLiquidityUrlPathParts.ts b/src/utils/getLiquidityUrlPathParts.ts index 05bb42bd4..913cbcdbd 100644 --- a/src/utils/getLiquidityUrlPathParts.ts +++ b/src/utils/getLiquidityUrlPathParts.ts @@ -1,6 +1,6 @@ // Constructing the two forward-slash-separated parts of the 'Add Liquidity' URL // Each part of the url represents a different side of the LP pair. -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' const getLiquidityUrlPathParts = ({ quoteTokenAddress, @@ -9,7 +9,7 @@ const getLiquidityUrlPathParts = ({ quoteTokenAddress: string tokenAddress: string }): string => { - const wBnbAddress = tokens.wbnb.address + const wBnbAddress = bscTokens.wbnb.address const firstPart = !quoteTokenAddress || quoteTokenAddress === wBnbAddress ? 'BNB' : quoteTokenAddress const secondPart = !tokenAddress || tokenAddress === wBnbAddress ? 'BNB' : tokenAddress return `${firstPart}/${secondPart}` diff --git a/src/utils/getLpAddress.ts b/src/utils/getLpAddress.ts index 3d7ac3232..44cf858a4 100644 --- a/src/utils/getLpAddress.ts +++ b/src/utils/getLpAddress.ts @@ -1,7 +1,7 @@ import { Token, Pair, ChainId } from '@pancakeswap/sdk' import { isAddress } from 'utils' -const getLpAddress = (token1: string | Token, token2: string | Token) => { +const getLpAddress = (token1: string | Token, token2: string | Token, chainId: number = ChainId.BSC) => { let token1AsTokenInstance = token1 let token2AsTokenInstance = token2 if (!token1 || !token2) { @@ -12,14 +12,14 @@ const getLpAddress = (token1: string | Token, token2: string | Token) => { if (!checksummedToken1Address) { return null } - token1AsTokenInstance = new Token(ChainId.MAINNET, checksummedToken1Address, 18) + token1AsTokenInstance = new Token(chainId, checksummedToken1Address, 18) } if (typeof token2 === 'string' || token2 instanceof String) { const checksummedToken2Address = isAddress(token2) if (!checksummedToken2Address) { return null } - token2AsTokenInstance = new Token(ChainId.MAINNET, checksummedToken2Address, 18) + token2AsTokenInstance = new Token(chainId, checksummedToken2Address, 18) } return Pair.getAddress(token1AsTokenInstance as Token, token2AsTokenInstance as Token) } diff --git a/src/utils/getRpcUrl.ts b/src/utils/getRpcUrl.ts deleted file mode 100644 index c9ed70d53..000000000 --- a/src/utils/getRpcUrl.ts +++ /dev/null @@ -1,22 +0,0 @@ -import sample from 'lodash/sample' - -if ( - process.env.NODE_ENV !== 'production' && - (!process.env.NEXT_PUBLIC_NODE_1 || !process.env.NEXT_PUBLIC_NODE_2 || !process.env.NEXT_PUBLIC_NODE_3) -) { - throw Error('One base RPC URL is undefined') -} - -// Array of available nodes to connect to -export const nodes = [process.env.NEXT_PUBLIC_NODE_1, process.env.NEXT_PUBLIC_NODE_2, process.env.NEXT_PUBLIC_NODE_3] - -const getNodeUrl = () => { - // Use custom node if available (both for development and production) - // However on the testnet it wouldn't work, so if on testnet - comment out the NEXT_PUBLIC_NODE_PRODUCTION from env file - if (process.env.NEXT_PUBLIC_NODE_PRODUCTION) { - return process.env.NEXT_PUBLIC_NODE_PRODUCTION - } - return sample(nodes) -} - -export default getNodeUrl diff --git a/src/utils/index.ts b/src/utils/index.ts index 50fe0c511..4c085a31a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -6,11 +6,9 @@ import { getAddress } from '@ethersproject/address' import { AddressZero } from '@ethersproject/constants' import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers' import { BigNumber } from '@ethersproject/bignumber' -import { CHAIN_ID } from 'config/constants/networks' -import { Token, Currency, ETHER } from '@pancakeswap/sdk' +import { Token, Currency, ETHER, ChainId } from '@pancakeswap/sdk' import { TokenAddressMap } from 'state/types' import { BASE_BSC_SCAN_URLS } from '../config' -import { simpleRpcProvider } from './providers' // returns the checksummed address if the address is valid, otherwise returns false export const isAddress = memoize((value: any): string | false => { @@ -26,7 +24,7 @@ export function getBscScanLink( type: 'transaction' | 'token' | 'address' | 'block' | 'countdown', chainIdOverride?: number, ): string { - const chainId = chainIdOverride || CHAIN_ID + const chainId = chainIdOverride || ChainId.BSC switch (type) { case 'transaction': { return `${BASE_BSC_SCAN_URLS[chainId]}/tx/${data}` @@ -47,7 +45,7 @@ export function getBscScanLink( } export function getBscScanLinkForNft(collectionAddress: string, tokenId: string): string { - return `${BASE_BSC_SCAN_URLS[CHAIN_ID]}/token/${collectionAddress}?a=${tokenId}` + return `${BASE_BSC_SCAN_URLS[ChainId.BSC]}/token/${collectionAddress}?a=${tokenId}` } // add 10% @@ -71,7 +69,7 @@ export function getContract(address: string, ABI: any, signer?: Signer | Provide throw Error(`Invalid 'address' parameter '${address}'.`) } - return new Contract(address, ABI, signer ?? simpleRpcProvider) + return new Contract(address, ABI, signer) } export function escapeRegExp(string: string): string { diff --git a/src/utils/providers.ts b/src/utils/providers.ts index 72ba736ae..bdbbe8806 100644 --- a/src/utils/providers.ts +++ b/src/utils/providers.ts @@ -1,8 +1,7 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers' -import getRpcUrl from 'utils/getRpcUrl' -const RPC_URL = getRpcUrl() +export const BSC_PROD_NODE = process.env.NEXT_PUBLIC_NODE_PRODUCTION || 'https://bsc.nodereal.io' -export const simpleRpcProvider = new StaticJsonRpcProvider(RPC_URL) +export const bscRpcProvider = new StaticJsonRpcProvider(BSC_PROD_NODE) export default null diff --git a/src/utils/serializeTokens.ts b/src/utils/serializeTokens.ts new file mode 100644 index 000000000..aa9ccc70a --- /dev/null +++ b/src/utils/serializeTokens.ts @@ -0,0 +1,9 @@ +import { serializeToken } from 'state/user/hooks/helpers' + +export function serializeTokens(unserializedTokens) { + const serializedTokens = Object.keys(unserializedTokens).reduce((accum, key) => { + return { ...accum, [key]: serializeToken(unserializedTokens[key]) } + }, {} as any) + + return serializedTokens +} diff --git a/src/utils/shouldShowSwapWarning.ts b/src/utils/shouldShowSwapWarning.ts index 8e3c7bd4d..2101bd079 100644 --- a/src/utils/shouldShowSwapWarning.ts +++ b/src/utils/shouldShowSwapWarning.ts @@ -4,7 +4,7 @@ import SwapWarningTokens from 'config/constants/swapWarningTokens' const swapWarningTokens = Object.values(SwapWarningTokens) const shouldShowSwapWarning = (swapCurrency: Token) => { - return swapWarningTokens.some((warningToken) => swapCurrency.address === warningToken.address) + return swapWarningTokens.some((warningToken) => swapCurrency.equals(warningToken)) } export default shouldShowSwapWarning diff --git a/src/utils/trades.test.ts b/src/utils/trades.test.ts index 30992c72b..fa7740063 100644 --- a/src/utils/trades.test.ts +++ b/src/utils/trades.test.ts @@ -3,9 +3,9 @@ import { BETTER_TRADE_LESS_HOPS_THRESHOLD } from 'config/constants' import { isTradeBetter } from './trades' describe('isTradeBetter', () => { - const token1 = new Token(ChainId.MAINNET, '0x0000000000000000000000000000000000000001', 18) - const token2 = new Token(ChainId.MAINNET, '0x0000000000000000000000000000000000000002', 18) - const token3 = new Token(ChainId.MAINNET, '0x0000000000000000000000000000000000000003', 18) + const token1 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000001', 18) + const token2 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000002', 18) + const token3 = new Token(ChainId.BSC, '0x0000000000000000000000000000000000000003', 18) const pair12 = new Pair(new TokenAmount(token1, JSBI.BigInt(20000)), new TokenAmount(token2, JSBI.BigInt(20000))) const pair23 = new Pair(new TokenAmount(token2, JSBI.BigInt(20000)), new TokenAmount(token3, JSBI.BigInt(30000))) diff --git a/src/utils/tryParseAmount.test.ts b/src/utils/tryParseAmount.test.ts index c4c1cf677..916e04358 100644 --- a/src/utils/tryParseAmount.test.ts +++ b/src/utils/tryParseAmount.test.ts @@ -1,4 +1,4 @@ -import { testnetTokens } from 'config/constants/tokens' +import { bscTestnetTokens } from 'config/constants/tokens' import tryParseAmount from './tryParseAmount' describe('utils/tryParseAmount', () => { @@ -10,6 +10,6 @@ describe('utils/tryParseAmount', () => { }) it('should pared value', () => { - expect(tryParseAmount('100', testnetTokens.cake)).toBeTruthy() + expect(tryParseAmount('100', bscTestnetTokens.cake)).toBeTruthy() }) }) diff --git a/src/utils/wallet.ts b/src/utils/wallet.ts index 9caa450bd..49d71fa45 100644 --- a/src/utils/wallet.ts +++ b/src/utils/wallet.ts @@ -4,16 +4,18 @@ import { ExternalProvider } from '@ethersproject/providers' import { ChainId } from '@pancakeswap/sdk' import { BAD_SRCS } from 'components/Logo/Logo' import { BASE_BSC_SCAN_URLS } from 'config' -import { nodes } from './getRpcUrl' +import { BSC_RPC_URLS, BSC_TESTNET_RPC_URLS } from '../config/constants/rpc' const NETWORK_CONFIG = { - [ChainId.MAINNET]: { + [ChainId.BSC]: { name: 'BNB Smart Chain Mainnet', - scanURL: BASE_BSC_SCAN_URLS[ChainId.MAINNET], + scanURL: BASE_BSC_SCAN_URLS[ChainId.BSC], + rpcUrls: BSC_RPC_URLS, }, - [ChainId.TESTNET]: { + [ChainId.BSC_TESTNET]: { name: 'BNB Smart Chain Testnet', - scanURL: BASE_BSC_SCAN_URLS[ChainId.TESTNET], + scanURL: BASE_BSC_SCAN_URLS[ChainId.BSC_TESTNET], + rpcUrls: BSC_TESTNET_RPC_URLS, }, } @@ -21,9 +23,8 @@ const NETWORK_CONFIG = { * Prompt the user to add BSC as a network on Metamask, or switch to BSC if the wallet is on a different network * @returns {boolean} true if the setup succeeded, false otherwise */ -export const setupNetwork = async (externalProvider?: ExternalProvider) => { +export const setupNetwork = async (chainId?: number, externalProvider?: ExternalProvider) => { const provider = externalProvider || window.ethereum - const chainId = parseInt(process.env.NEXT_PUBLIC_CHAIN_ID, 10) as keyof typeof NETWORK_CONFIG if (!NETWORK_CONFIG[chainId]) { console.error('Invalid chain id') return false @@ -49,7 +50,7 @@ export const setupNetwork = async (externalProvider?: ExternalProvider) => { symbol: 'bnb', decimals: 18, }, - rpcUrls: nodes, + rpcUrls: NETWORK_CONFIG[chainId].rpcUrls, blockExplorerUrls: [`${NETWORK_CONFIG[chainId].scanURL}/`], }, ], diff --git a/src/utils/web3React.ts b/src/utils/web3React.ts index 7671a7274..eaff121d8 100644 --- a/src/utils/web3React.ts +++ b/src/utils/web3React.ts @@ -4,25 +4,23 @@ import { AbstractConnector } from '@web3-react/abstract-connector' import { ChainId } from '@pancakeswap/sdk' import { BscConnector } from '@binance-chain/bsc-connector' import { ConnectorNames } from '@pancakeswap/uikit' +import useWeb3Provider from 'hooks/useActiveWeb3React' import { hexlify } from '@ethersproject/bytes' import { toUtf8Bytes } from '@ethersproject/strings' import { Web3Provider } from '@ethersproject/providers' -import { CHAIN_ID } from 'config/constants/networks' -import getNodeUrl from './getRpcUrl' const POLLING_INTERVAL = 12000 -const rpcUrl = getNodeUrl() -const chainId = parseInt(CHAIN_ID, 10) -export const injected = new InjectedConnector({ supportedChainIds: [chainId] }) +const SUPPORTED_CHAIN_ID = [ChainId.BSC, ChainId.BSC_TESTNET] + +export const injected = new InjectedConnector({ supportedChainIds: SUPPORTED_CHAIN_ID }) const walletconnect = new WalletConnectConnector({ - rpc: { [chainId]: rpcUrl }, qrcode: true, pollingInterval: POLLING_INTERVAL, }) -const bscConnector = new BscConnector({ supportedChainIds: [chainId] }) +const bscConnector = new BscConnector({ supportedChainIds: SUPPORTED_CHAIN_ID }) export const connectorsByName = { [ConnectorNames.Injected]: injected, @@ -30,15 +28,15 @@ export const connectorsByName = { [ConnectorNames.BSC]: bscConnector, [ConnectorNames.Blocto]: async () => { const { BloctoConnector } = await import('@blocto/blocto-connector') - return new BloctoConnector({ chainId, rpc: rpcUrl }) + return new BloctoConnector({ chainId: ChainId.BSC, rpc: 'https://bsc.nodereal.io' }) }, [ConnectorNames.WalletLink]: async () => { const { WalletLinkConnector } = await import('@web3-react/walletlink-connector') return new WalletLinkConnector({ - url: rpcUrl, + url: 'https://pancakeswap.finance', appName: 'PancakeSwap', appLogoUrl: 'https://pancakeswap.com/logo.png', - supportedChainIds: [ChainId.MAINNET, ChainId.TESTNET], + supportedChainIds: SUPPORTED_CHAIN_ID, }) }, } as const @@ -49,6 +47,34 @@ export const getLibrary = (provider): Web3Provider => { return library } +export function useSignMessage() { + const { library, connector, account } = useWeb3Provider() + const signMessage = async ({ message }) => { + if (window.BinanceChain && connector instanceof BscConnector) { + const { signature } = await window.BinanceChain.bnbSign(account, message) + return signature + } + + /** + * Wallet Connect does not sign the message correctly unless you use their method + * @see https://github.com/WalletConnect/walletconnect-monorepo/issues/462 + */ + // @ts-ignore + if (library.provider?.wc) { + const wcMessage = hexlify(toUtf8Bytes(message)) + // @ts-ignore + const signature = await library.provider?.wc.signPersonalMessage([wcMessage, account]) + return signature + } + + return library.getSigner(account).signMessage(message) + } + + return { + signMessageAsync: signMessage, + } +} + /** * BSC Wallet requires a different sign method * @see https://docs.binance.org/smart-chain/wallet/wallet_api.html#binancechainbnbsignaddress-string-message-string-promisepublickey-string-signature-string diff --git a/src/utils/wrappedCurrency.ts b/src/utils/wrappedCurrency.ts index 76ff22e4d..443c0532d 100644 --- a/src/utils/wrappedCurrency.ts +++ b/src/utils/wrappedCurrency.ts @@ -1,7 +1,7 @@ -import { ChainId, Currency, CurrencyAmount, ETHER, Token, TokenAmount, WETH } from '@pancakeswap/sdk' +import { ChainId, Currency, CurrencyAmount, ETHER, Token, TokenAmount, WNATIVE } from '@pancakeswap/sdk' export function wrappedCurrency(currency: Currency | undefined, chainId: ChainId | undefined): Token | undefined { - return chainId && currency === ETHER ? WETH[chainId] : currency instanceof Token ? currency : undefined + return chainId && currency === ETHER ? WNATIVE[chainId] : currency instanceof Token ? currency : undefined } export function wrappedCurrencyAmount( @@ -13,6 +13,6 @@ export function wrappedCurrencyAmount( } export function unwrappedToken(token: Token): Currency { - if (token.equals(WETH[token.chainId])) return ETHER + if (token.equals(WNATIVE[token.chainId])) return ETHER return token } diff --git a/src/views/AddLiquidity/index.tsx b/src/views/AddLiquidity/index.tsx index e3b6c3c69..620bb3c81 100644 --- a/src/views/AddLiquidity/index.tsx +++ b/src/views/AddLiquidity/index.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react' import { BigNumber, BigNumberish } from '@ethersproject/bignumber' import { TransactionResponse } from '@ethersproject/providers' -import { currencyEquals, ETHER, JSBI, TokenAmount, WETH, MINIMUM_LIQUIDITY } from '@pancakeswap/sdk' +import { currencyEquals, ETHER, JSBI, TokenAmount, WNATIVE, MINIMUM_LIQUIDITY } from '@pancakeswap/sdk' import { Button, Text, @@ -17,18 +17,17 @@ import { logError } from 'utils/sentry' import { useIsTransactionUnsupported, useIsTransactionWarning } from 'hooks/Trades' import { useTranslation } from 'contexts/Localization' import UnsupportedCurrencyFooter from 'components/UnsupportedCurrencyFooter' +import { useZapContract } from 'hooks/useContract' import useActiveWeb3React from 'hooks/useActiveWeb3React' -import { getZapContract } from 'utils/contractHelpers' import { getZapAddress } from 'utils/addressHelpers' import { getLPSymbol } from 'utils/getLpSymbol' import { useRouter } from 'next/router' -import { CHAIN_ID } from 'config/constants/networks' import { callWithEstimateGas } from 'utils/calls' import { ContractMethodName } from 'utils/types' import { transactionErrorToUserReadableMessage } from 'utils/transactionErrorToUserReadableMessage' import { useLPApr } from 'state/swap/hooks' import { ROUTER_ADDRESS } from 'config/constants/exchange' -import { serializeTokens } from 'config/constants/tokens' +import { CAKE } from 'config/constants/tokens' import { LightCard } from '../../components/Card' import { AutoColumn, ColumnCenter } from '../../components/Layout/Column' import CurrencyInputPanel from '../../components/CurrencyInputPanel' @@ -70,15 +69,14 @@ const zapAddress = getZapAddress() export default function AddLiquidity() { const router = useRouter() - const tokens = serializeTokens() + const { account, chainId, library } = useActiveWeb3React() const expertMode = useIsExpertMode() const [zapMode] = useZapModeManager() const [temporarilyZapMode, setTemporarilyZapMode] = useState(zapMode) - const [currencyIdA, currencyIdB] = router.query.currency || [tokens.bnb.symbol, tokens.cake.address] + const [currencyIdA, currencyIdB] = router.query.currency || [WNATIVE[chainId]?.address, CAKE[chainId]?.address] const [steps, setSteps] = useState(Steps.Choose) - const { account, chainId, library } = useActiveWeb3React() const dispatch = useAppDispatch() const { t } = useTranslation() const gasPrice = useGasPrice() @@ -224,11 +222,11 @@ export default function AddLiquidity() { // check whether the user has approved the router on the tokens const [approvalA, approveACallback] = useApproveCallback( parsedAmounts[Field.CURRENCY_A], - preferZapInstead ? zapAddress : ROUTER_ADDRESS[CHAIN_ID], + preferZapInstead ? zapAddress : ROUTER_ADDRESS[chainId], ) const [approvalB, approveBCallback] = useApproveCallback( parsedAmounts[Field.CURRENCY_B], - preferZapInstead ? zapAddress : ROUTER_ADDRESS[CHAIN_ID], + preferZapInstead ? zapAddress : ROUTER_ADDRESS[chainId], ) const addTransaction = useTransactionAdder() @@ -338,6 +336,8 @@ export default function AddLiquidity() { const addIsUnsupported = useIsTransactionUnsupported(currencies?.CURRENCY_A, currencies?.CURRENCY_B) const addIsWarning = useIsTransactionWarning(currencies?.CURRENCY_A, currencies?.CURRENCY_B) + const zapContract = useZapContract(true) + const [onPresentAddLiquidityModal] = useModal( let args let value: BigNumberish | null @@ -512,8 +510,8 @@ export default function AddLiquidity() { const oneCurrencyIsWBNB = Boolean( chainId && - ((currencyA && currencyEquals(currencyA, WETH[chainId])) || - (currencyB && currencyEquals(currencyB, WETH[chainId]))), + ((currencyA && currencyEquals(currencyA, WNATIVE[chainId])) || + (currencyB && currencyEquals(currencyB, WNATIVE[chainId]))), ) const noAnyInputAmount = !parsedAmounts[Field.CURRENCY_A] && !parsedAmounts[Field.CURRENCY_B] diff --git a/src/views/FarmAuction/components/PlaceBidModal.tsx b/src/views/FarmAuction/components/PlaceBidModal.tsx index f518842e4..2f2716a03 100644 --- a/src/views/FarmAuction/components/PlaceBidModal.tsx +++ b/src/views/FarmAuction/components/PlaceBidModal.tsx @@ -18,7 +18,7 @@ import { ConnectedBidder, FetchStatus } from 'config/constants/types' import { usePriceCakeBusd } from 'state/farms/hooks' import { useCallWithGasPrice } from 'hooks/useCallWithGasPrice' import { ToastDescriptionWithTx } from 'components/Toast' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { requiresApproval } from 'utils/requiresApproval' const StyledModal = styled(Modal)` @@ -66,7 +66,7 @@ const PlaceBidModal: React.FC = ({ const [userNotEnoughCake, setUserNotEnoughCake] = useState(false) const [errorText, setErrorText] = useState(null) - const { balance: userCake, fetchStatus } = useTokenBalance(tokens.cake.address) + const { balance: userCake, fetchStatus } = useTokenBalance(bscTokens.cake.address) const userCakeBalance = getBalanceAmount(userCake) const cakePriceBusd = usePriceCakeBusd() diff --git a/src/views/FarmAuction/helpers.tsx b/src/views/FarmAuction/helpers.tsx index 44c9a1417..03e0d3985 100644 --- a/src/views/FarmAuction/helpers.tsx +++ b/src/views/FarmAuction/helpers.tsx @@ -1,7 +1,7 @@ import { toDate, add, differenceInHours } from 'date-fns' import { BSC_BLOCK_TIME, DEFAULT_TOKEN_DECIMAL } from 'config' import { getBidderInfo } from 'config/constants/farmAuctions' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import { AuctionsResponse, FarmAuctionContractStatus, BidsPerAuction } from 'utils/types' import { Auction, AuctionStatus, Bidder, BidderAuction } from 'config/constants/types' import { ethersToBigNumber } from 'utils/bigNumber' @@ -85,7 +85,7 @@ const getDateForBlock = async (currentBlock: number, block: number) => { // if block already happened we can get timestamp via .getBlock(block) if (currentBlock > block) { try { - const { timestamp } = await simpleRpcProvider.getBlock(block) + const { timestamp } = await bscRpcProvider.getBlock(block) return toDate(timestamp * 1000) } catch { add(new Date(), { seconds: secondsUntilStart }) @@ -110,7 +110,7 @@ export const processAuctionData = async ( } // Get all required data and blocks - const currentBlock = currentBlockNumber || (await simpleRpcProvider.getBlockNumber()) + const currentBlock = currentBlockNumber || (await bscRpcProvider.getBlockNumber()) const [startDate, endDate] = await Promise.all([ getDateForBlock(currentBlock, processedAuctionData.startBlock), getDateForBlock(currentBlock, processedAuctionData.endBlock), diff --git a/src/views/Farms/Farms.tsx b/src/views/Farms/Farms.tsx index 5d985f719..2d8ed0800 100644 --- a/src/views/Farms/Farms.tsx +++ b/src/views/Farms/Farms.tsx @@ -169,7 +169,7 @@ const Farms: React.FC = ({ children }) => { new BigNumber(farm.poolWeight), cakePrice, totalLiquidity, - farm.lpAddresses[ChainId.MAINNET], + farm.lpAddresses[ChainId.BSC], regularCakePerBlock, ) : { cakeRewardsApr: 0, lpRewardsApr: 0 } diff --git a/src/views/Home/components/CakeDataRow.tsx b/src/views/Home/components/CakeDataRow.tsx index de8b27dcb..0d449f41c 100644 --- a/src/views/Home/components/CakeDataRow.tsx +++ b/src/views/Home/components/CakeDataRow.tsx @@ -1,7 +1,7 @@ import { Flex, Heading, Skeleton, Text } from '@pancakeswap/uikit' import Balance from 'components/Balance' import cakeAbi from 'config/abi/cake.json' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { useTranslation } from 'contexts/Localization' import useIntersectionObserver from 'hooks/useIntersectionObserver' import { useEffect, useState } from 'react' @@ -88,9 +88,9 @@ const CakeDataRow = () => { } = useSWR( loadData ? ['cakeDataRow'] : null, async () => { - const totalSupplyCall = { address: tokens.cake.address, name: 'totalSupply' } + const totalSupplyCall = { address: bscTokens.cake.address, name: 'totalSupply' } const burnedTokenCall = { - address: tokens.cake.address, + address: bscTokens.cake.address, name: 'balanceOf', params: ['0x000000000000000000000000000000000000dEaD'], } diff --git a/src/views/Home/hooks/useGetTopFarmsByApr.tsx b/src/views/Home/hooks/useGetTopFarmsByApr.tsx index 297dbc62a..f9fb3a937 100644 --- a/src/views/Home/hooks/useGetTopFarmsByApr.tsx +++ b/src/views/Home/hooks/useGetTopFarmsByApr.tsx @@ -51,7 +51,7 @@ const useGetTopFarmsByApr = (isIntersecting: boolean) => { farm.poolWeight, cakePriceBusd, totalLiquidity, - farm.lpAddresses[ChainId.MAINNET], + farm.lpAddresses[ChainId.BSC], regularCakePerBlock, ) return { ...farm, apr: cakeRewardsApr, lpRewardsApr } diff --git a/src/views/Ifos/SoonIfo.tsx b/src/views/Ifos/SoonIfo.tsx index 74f8118a6..34e127e55 100644 --- a/src/views/Ifos/SoonIfo.tsx +++ b/src/views/Ifos/SoonIfo.tsx @@ -1,4 +1,4 @@ -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import IfoContainer from './components/IfoContainer' import IfoSteps from './components/IfoSteps' import ComingSoonSection from './components/ComingSoonSection' @@ -7,7 +7,7 @@ const SoonIfo = () => ( } ifoSteps={ - + } /> ) diff --git a/src/views/Ifos/components/IfoFoldableCard/Achievement.tsx b/src/views/Ifos/components/IfoFoldableCard/Achievement.tsx index 3862640cf..bdcd3ea38 100644 --- a/src/views/Ifos/components/IfoFoldableCard/Achievement.tsx +++ b/src/views/Ifos/components/IfoFoldableCard/Achievement.tsx @@ -12,7 +12,7 @@ import { Link, TelegramIcon, } from '@pancakeswap/uikit' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { useTranslation } from 'contexts/Localization' import { PublicIfoData } from 'views/Ifos/types' import { Ifo } from 'config/constants/types' @@ -116,7 +116,7 @@ const IfoAchievement: React.FC = ({ ifo, publicIfoData }) => { {t('Commit ~%amount% %symbol% in total to earn!', { amount: minLpForAchievement, - symbol: ifo.currency === tokens.cake ? 'CAKE' : 'LP', + symbol: ifo.currency === bscTokens.cake ? 'CAKE' : 'LP', })} ) : ( diff --git a/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/ContributeModal.tsx b/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/ContributeModal.tsx index f387fb207..4fbe3dfab 100644 --- a/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/ContributeModal.tsx +++ b/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/ContributeModal.tsx @@ -29,7 +29,7 @@ import { useCallWithGasPrice } from 'hooks/useCallWithGasPrice' import useToast from 'hooks/useToast' import { DEFAULT_TOKEN_DECIMAL } from 'config' import { useERC20 } from 'hooks/useContract' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { requiresApproval } from 'utils/requiresApproval' const MessageTextLink = styled(Link)` @@ -99,7 +99,7 @@ const ContributeModal: React.FC = ({ const raisingTokenContractApprover = useERC20(currency.address) const { t } = useTranslation() const valueWithTokenDecimals = new BigNumber(value).times(DEFAULT_TOKEN_DECIMAL) - const label = currency === tokens.cake ? t('Max. CAKE entry') : t('Max. token entry') + const label = currency === bscTokens.cake ? t('Max. CAKE entry') : t('Max. token entry') const { isApproving, isApproved, isConfirmed, isConfirming, handleApprove, handleConfirm } = useApproveConfirmTransaction({ diff --git a/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardDetails.tsx b/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardDetails.tsx index 94551a3f2..09cf1d81c 100644 --- a/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardDetails.tsx +++ b/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardDetails.tsx @@ -1,5 +1,5 @@ import { ReactNode } from 'react' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { Text, Flex, Box, Skeleton, TooltipText, useTooltip } from '@pancakeswap/uikit' import { PublicIfoData, WalletIfoData } from 'views/Ifos/types' import { useTranslation } from 'contexts/Localization' @@ -53,7 +53,7 @@ const FooterEntry: React.FC = ({ label, value, tooltipContent } const MaxTokenEntry = ({ maxToken, ifo, poolId }: { maxToken: number; ifo: Ifo; poolId: PoolIds }) => { - const isCurrencyCake = ifo.currency === tokens.cake + const isCurrencyCake = ifo.currency === bscTokens.cake const isV3 = ifo.version >= 3 const { t } = useTranslation() diff --git a/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardTokens.tsx b/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardTokens.tsx index 8942d7a2a..67f66a45e 100644 --- a/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardTokens.tsx +++ b/src/views/Ifos/components/IfoFoldableCard/IfoPoolCard/IfoCardTokens.tsx @@ -16,7 +16,7 @@ import { import { useWeb3React } from '@web3-react/core' import { Token } from '@pancakeswap/sdk' import { Ifo, PoolIds } from 'config/constants/types' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { cakeBnbLpToken } from 'config/constants/ifo' import { PublicIfoData, WalletIfoData } from 'views/Ifos/types' import { useTranslation } from 'contexts/Localization' @@ -68,7 +68,7 @@ const TokenSection: React.FC = ({ primaryToken, secondaryToke const CommitTokenSection: React.FC = ({ commitToken, ...props }) => { if (commitToken.equals(cakeBnbLpToken)) { - return + return } return } diff --git a/src/views/Ifos/hooks/v2/useGetPublicIfoData.ts b/src/views/Ifos/hooks/v2/useGetPublicIfoData.ts index 41e11e26d..6cf24482b 100644 --- a/src/views/Ifos/hooks/v2/useGetPublicIfoData.ts +++ b/src/views/Ifos/hooks/v2/useGetPublicIfoData.ts @@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js' import { useState, useCallback } from 'react' import { BSC_BLOCK_TIME } from 'config' import ifoV2Abi from 'config/abi/ifoV2.json' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { Ifo, IfoStatus } from 'config/constants/types' import { FixedNumber } from '@ethersproject/bignumber' @@ -32,7 +32,7 @@ const useGetPublicIfoData = (ifo: Ifo): PublicIfoData => { const { address, releaseBlockNumber } = ifo const cakePriceUsd = usePriceCakeBusd() const lpTokenPriceInUsd = useLpTokenPrice(ifo.currency.symbol) - const currencyPriceInUSD = ifo.currency === tokens.cake ? cakePriceUsd : lpTokenPriceInUsd + const currencyPriceInUSD = ifo.currency === bscTokens.cake ? cakePriceUsd : lpTokenPriceInUsd const [state, setState] = useState({ isInitialized: false, diff --git a/src/views/Ifos/hooks/v3/useGetPublicIfoData.ts b/src/views/Ifos/hooks/v3/useGetPublicIfoData.ts index 16129910f..2168b0dac 100644 --- a/src/views/Ifos/hooks/v3/useGetPublicIfoData.ts +++ b/src/views/Ifos/hooks/v3/useGetPublicIfoData.ts @@ -3,7 +3,7 @@ import { useState, useCallback } from 'react' import { BSC_BLOCK_TIME } from 'config' import ifoV2Abi from 'config/abi/ifoV2.json' import ifoV3Abi from 'config/abi/ifoV3.json' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { Ifo, IfoStatus } from 'config/constants/types' import { useLpTokenPrice, usePriceCakeBusd } from 'state/farms/hooks' @@ -39,7 +39,7 @@ const useGetPublicIfoData = (ifo: Ifo): PublicIfoData => { const { address, releaseBlockNumber, version } = ifo const cakePriceUsd = usePriceCakeBusd() const lpTokenPriceInUsd = useLpTokenPrice(ifo.currency.symbol) - const currencyPriceInUSD = ifo.currency === tokens.cake ? cakePriceUsd : lpTokenPriceInUsd + const currencyPriceInUSD = ifo.currency === bscTokens.cake ? cakePriceUsd : lpTokenPriceInUsd const [state, setState] = useState({ isInitialized: false, diff --git a/src/views/Lottery/components/BuyTicketsModal/BuyTicketsModal.tsx b/src/views/Lottery/components/BuyTicketsModal/BuyTicketsModal.tsx index 6941e7989..69b591dc2 100644 --- a/src/views/Lottery/components/BuyTicketsModal/BuyTicketsModal.tsx +++ b/src/views/Lottery/components/BuyTicketsModal/BuyTicketsModal.tsx @@ -17,7 +17,7 @@ import { } from '@pancakeswap/uikit' import { useTranslation } from 'contexts/Localization' import { useWeb3React } from '@web3-react/core' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { getFullDisplayBalance } from 'utils/formatBalance' import { BIG_ZERO } from 'utils/bigNumber' import { useAppDispatch } from 'state' @@ -85,7 +85,7 @@ const BuyTicketsModal: React.FC = ({ onDismiss }) => { const lotteryContract = useLotteryV2Contract() const { reader: cakeContractReader, signer: cakeContractApprover } = useCake() const { toastSuccess } = useToast() - const { balance: userCake, fetchStatus } = useTokenBalance(tokens.cake.address) + const { balance: userCake, fetchStatus } = useTokenBalance(bscTokens.cake.address) // balance from useTokenBalance causes rerenders in effects as a new BigNumber is instantiated on each render, hence memoising it using the stringified value below. const stringifiedUserCake = userCake.toJSON() const memoisedUserCake = useMemo(() => new BigNumber(stringifiedUserCake), [stringifiedUserCake]) diff --git a/src/views/Migration/components/MigrationStep1/OldFarm/index.tsx b/src/views/Migration/components/MigrationStep1/OldFarm/index.tsx index 751eac881..ade67c790 100644 --- a/src/views/Migration/components/MigrationStep1/OldFarm/index.tsx +++ b/src/views/Migration/components/MigrationStep1/OldFarm/index.tsx @@ -41,7 +41,7 @@ const OldFarmStep1: React.FC = () => { new BigNumber(farm.poolWeight), cakePrice, totalLiquidity, - farm.lpAddresses[ChainId.MAINNET], + farm.lpAddresses[ChainId.BSC], CAKE_PER_YEAR, ) return { ...farm, apr: cakeRewardsApr, lpRewardsApr, liquidity: totalLiquidity } diff --git a/src/views/Migration/components/MigrationStep2/NewFarm/index.tsx b/src/views/Migration/components/MigrationStep2/NewFarm/index.tsx index c0afc66a5..3b916efab 100644 --- a/src/views/Migration/components/MigrationStep2/NewFarm/index.tsx +++ b/src/views/Migration/components/MigrationStep2/NewFarm/index.tsx @@ -54,7 +54,7 @@ const OldFarmStep1: React.FC = () => { new BigNumber(farm.poolWeight), cakePrice, totalLiquidity, - farm.lpAddresses[ChainId.MAINNET], + farm.lpAddresses[ChainId.BSC], regularCakePerBlock, ) return { ...farm, apr: cakeRewardsApr, lpRewardsApr, liquidity: totalLiquidity } diff --git a/src/views/Migration/hook/V1/Pool/useFetchIfoPool.ts b/src/views/Migration/hook/V1/Pool/useFetchIfoPool.ts index 4d896c701..ea1c89c3d 100644 --- a/src/views/Migration/hook/V1/Pool/useFetchIfoPool.ts +++ b/src/views/Migration/hook/V1/Pool/useFetchIfoPool.ts @@ -8,7 +8,7 @@ import { fetchVaultFees } from 'state/pools/fetchVaultPublic' import type { Signer } from '@ethersproject/abstract-signer' import type { Provider } from '@ethersproject/providers' import { Contract } from '@ethersproject/contracts' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import cakeVaultAbi from 'config/abi/cakeVault.json' import { FAST_INTERVAL } from 'config/constants' import { VaultKey } from 'state/types' @@ -18,7 +18,7 @@ export const ifoPoolV1Contract = '0x1B2A2f6ed4A1401E8C73B4c2B6172455ce2f78E8' export const cakeVaultAddress = '0xa80240Eb5d7E05d3F250cF000eEc0891d00b51CC' const getCakeVaultContract = (signer?: Signer | Provider) => { - const signerOrProvider = signer ?? simpleRpcProvider + const signerOrProvider = signer ?? bscRpcProvider return new Contract(cakeVaultAddress, cakeVaultAbi, signerOrProvider) as any } diff --git a/src/views/Migration/hook/V1/Pool/useFetchUserPools.ts b/src/views/Migration/hook/V1/Pool/useFetchUserPools.ts index a1df5951e..174a33765 100644 --- a/src/views/Migration/hook/V1/Pool/useFetchUserPools.ts +++ b/src/views/Migration/hook/V1/Pool/useFetchUserPools.ts @@ -4,9 +4,10 @@ import { useFastRefreshEffect } from 'hooks/useRefreshEffect' import { SerializedPool } from 'state/types' import { transformPool } from 'state/pools/helpers' import { getCakeContract } from 'utils/contractHelpers' -import { CHAIN_ID } from 'config/constants/networks' +import useActiveWeb3React from 'hooks/useActiveWeb3React' import { PoolCategory } from 'config/constants/types' -import { serializeTokens } from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' +import { serializeTokens } from 'utils/serializeTokens' import { fetchUserStakeBalances, fetchUserPendingRewards } from './fetchPoolsUser' export interface PoolsState { @@ -14,7 +15,7 @@ export interface PoolsState { userDataLoaded: boolean } -const serializedTokens = serializeTokens() +const serializedTokens = serializeTokens(bscTokens) const cakeContract = getCakeContract() const initialData = { @@ -35,6 +36,7 @@ const initialData = { } export const useFetchUserPools = (account) => { + const { chainId } = useActiveWeb3React() const [userPoolsData, setPoolsUserData] = useState(initialData) const fetchUserPoolsData = useCallback(() => { @@ -44,7 +46,7 @@ export const useFetchUserPools = (account) => { const [stakedBalances, pendingRewards, totalStaking] = await Promise.all([ fetchUserStakeBalances(account), fetchUserPendingRewards(account), - cakeContract.balanceOf(initialData.data.contractAddress[CHAIN_ID]), + cakeContract.balanceOf(initialData.data.contractAddress[chainId]), ]) const userData = { @@ -70,7 +72,7 @@ export const useFetchUserPools = (account) => { fetchPoolsUserDataAsync() } - }, [account]) + }, [account, chainId]) useFastRefreshEffect(() => { fetchUserPoolsData() diff --git a/src/views/Nft/market/components/BuySellModals/BuyModal/index.tsx b/src/views/Nft/market/components/BuySellModals/BuyModal/index.tsx index ca3c5e54e..bb8f32603 100644 --- a/src/views/Nft/market/components/BuySellModals/BuyModal/index.tsx +++ b/src/views/Nft/market/components/BuySellModals/BuyModal/index.tsx @@ -6,8 +6,7 @@ import { useTranslation, TranslateFunction } from 'contexts/Localization' import useTokenBalance, { useGetBnbBalance } from 'hooks/useTokenBalance' import { getBalanceNumber } from 'utils/formatBalance' import { ethersToBigNumber } from 'utils/bigNumber' -import tokens from 'config/constants/tokens' -import { CHAIN_ID } from 'config/constants/networks' +import { bscTokens } from 'config/constants/tokens' import { ChainId } from '@pancakeswap/sdk' import { parseUnits, formatEther } from '@ethersproject/units' import { useERC20, useNftMarketContract } from 'hooks/useContract' @@ -37,8 +36,7 @@ interface BuyModalProps extends InjectedModalProps { } // NFT WBNB in testnet contract is different -const wbnbAddress = - CHAIN_ID === String(ChainId.MAINNET) ? tokens.wbnb.address : '0x094616f0bdfb0b526bd735bf66eca0ad254ca81f' +const TESTNET_WBNB_NFT_ADDRESS = '0x094616f0bdfb0b526bd735bf66eca0ad254ca81f' const BuyModal: React.FC = ({ nftToBuy, onDismiss }) => { const [stage, setStage] = useState(BuyingStage.REVIEW) @@ -49,7 +47,8 @@ const BuyModal: React.FC = ({ nftToBuy, onDismiss }) => { const { t } = useTranslation() const { callWithGasPrice } = useCallWithGasPrice() - const { account } = useWeb3React() + const { account, chainId } = useWeb3React() + const wbnbAddress = chainId === ChainId.BSC_TESTNET ? TESTNET_WBNB_NFT_ADDRESS : bscTokens.wbnb.address const wbnbContractReader = useERC20(wbnbAddress, false) const wbnbContractApprover = useERC20(wbnbAddress) const nftMarketContract = useNftMarketContract() diff --git a/src/views/Predictions/components/v1/V1ClaimCheck.tsx b/src/views/Predictions/components/v1/V1ClaimCheck.tsx index 8421305b1..e886755a4 100644 --- a/src/views/Predictions/components/v1/V1ClaimCheck.tsx +++ b/src/views/Predictions/components/v1/V1ClaimCheck.tsx @@ -5,7 +5,7 @@ import { useTranslation } from 'contexts/Localization' import { Box, Flex, Text, ChevronRightIcon, useModal } from '@pancakeswap/uikit' import Loading from 'components/Loading' import useLocalDispatch from 'contexts/LocalRedux/useLocalDispatch' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { Bet } from 'state/types' import { transformBetResponse } from 'state/predictions/helpers' import { getPredictionsV1Address } from 'utils/addressHelpers' @@ -34,7 +34,7 @@ const ClaimCheck = () => { const [onPresentCollectWinningsModal] = useModal( { }) if (unclaimedBets.length > 0) { - const transformer = transformBetResponse(tokens.bnb) + const transformer = transformBetResponse(bscTokens.bnb) setHistory(unclaimedBets.map(transformer)) onPresentCollectWinningsModal() } else { diff --git a/src/views/Predictions/context/config.ts b/src/views/Predictions/context/config.ts index 36f37506f..b7f781d75 100644 --- a/src/views/Predictions/context/config.ts +++ b/src/views/Predictions/context/config.ts @@ -2,7 +2,7 @@ import addresses from 'config/constants/contracts' import { GRAPH_API_PREDICTION_CAKE, GRAPH_API_PREDICTION_BNB } from 'config/constants/endpoints' import { getAddress } from 'utils/addressHelpers' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { BigNumber } from '@ethersproject/bignumber' const DEFAULT_MIN_PRICE_USD_DISPLAYED = BigNumber.from(10000) @@ -13,13 +13,13 @@ export default { api: GRAPH_API_PREDICTION_BNB, chainlinkOracleAddress: getAddress(addresses.chainlinkOracleBNB), minPriceUsdDisplayed: DEFAULT_MIN_PRICE_USD_DISPLAYED, - token: tokens.bnb, + token: bscTokens.bnb, }, CAKE: { address: getAddress(addresses.predictionsCAKE), api: GRAPH_API_PREDICTION_CAKE, chainlinkOracleAddress: getAddress(addresses.chainlinkOracleCAKE), minPriceUsdDisplayed: DEFAULT_MIN_PRICE_USD_DISPLAYED, - token: tokens.cake, + token: bscTokens.cake, }, } diff --git a/src/views/ProfileCreation/UserName.tsx b/src/views/ProfileCreation/UserName.tsx index cc3f1eebd..6cf95bc3c 100644 --- a/src/views/ProfileCreation/UserName.tsx +++ b/src/views/ProfileCreation/UserName.tsx @@ -21,9 +21,8 @@ import { formatUnits } from '@ethersproject/units' import { API_PROFILE } from 'config/constants/endpoints' import useToast from 'hooks/useToast' import { useGetCakeBalance } from 'hooks/useTokenBalance' -import { signMessage } from 'utils/web3React' +import { useSignMessage } from 'utils/web3React' import fetchWithTimeout from 'utils/fetchWithTimeout' -import useWeb3Provider from 'hooks/useActiveWeb3React' import { useTranslation } from 'contexts/Localization' import { FetchStatus } from 'config/constants/types' import ConfirmProfileCreationModal from './ConfirmProfileCreationModal' @@ -63,7 +62,7 @@ const UserName: React.FC = () => { const { t } = useTranslation() const { account } = useWeb3React() const { toastError } = useToast() - const { library, connector } = useWeb3Provider() + const { signMessageAsync } = useSignMessage() const [existingUserState, setExistingUserState] = useState(ExistingUserState.IDLE) const [isValid, setIsValid] = useState(false) const [isLoading, setIsLoading] = useState(false) @@ -143,7 +142,7 @@ const UserName: React.FC = () => { try { setIsLoading(true) - const signature = await signMessage(connector, library, account, userName) + const signature = await signMessageAsync({ message: userName }) const response = await fetch(`${API_PROFILE}/api/users/register`, { method: 'POST', headers: { diff --git a/src/views/RemoveLiquidity/index.tsx b/src/views/RemoveLiquidity/index.tsx index 8568da61f..6bee09197 100644 --- a/src/views/RemoveLiquidity/index.tsx +++ b/src/views/RemoveLiquidity/index.tsx @@ -5,7 +5,7 @@ import { Contract } from '@ethersproject/contracts' import { TransactionResponse } from '@ethersproject/providers' import { useRouter } from 'next/router' import useToast from 'hooks/useToast' -import { Currency, currencyEquals, ETHER, Percent, WETH } from '@pancakeswap/sdk' +import { Currency, currencyEquals, ETHER, Percent, WNATIVE } from '@pancakeswap/sdk' import { Button, Text, @@ -26,7 +26,6 @@ import { getLPSymbol } from 'utils/getLpSymbol' import { getZapAddress } from 'utils/addressHelpers' import { ZapCheckbox } from 'components/CurrencyInputPanel/ZapCheckbox' import { useTranslation } from 'contexts/Localization' -import { CHAIN_ID } from 'config/constants/networks' import { useLPApr } from 'state/swap/hooks' import { ROUTER_ADDRESS } from 'config/constants/exchange' import { transactionErrorToUserReadableMessage } from 'utils/transactionErrorToUserReadableMessage' @@ -148,7 +147,7 @@ export default function RemoveLiquidity() { const [signatureData, setSignatureData] = useState<{ v: number; r: string; s: string; deadline: number } | null>(null) const [approval, approveCallback] = useApproveCallback( parsedAmounts[Field.LIQUIDITY], - isZap ? getZapAddress() : ROUTER_ADDRESS[CHAIN_ID], + isZap ? getZapAddress() : ROUTER_ADDRESS[chainId], ) async function onAttemptToApprove() { @@ -183,7 +182,7 @@ export default function RemoveLiquidity() { ] const message = { owner: account, - spender: ROUTER_ADDRESS[CHAIN_ID], + spender: ROUTER_ADDRESS[chainId], value: liquidityAmount.raw.toString(), nonce: nonce.toHexString(), deadline: deadline.toNumber(), @@ -260,7 +259,7 @@ export default function RemoveLiquidity() { let methodName let args - if (oneCurrencyIsBNB && tokenToReceive.toLowerCase() === WETH[chainId].address.toLowerCase()) { + if (oneCurrencyIsBNB && tokenToReceive.toLowerCase() === WNATIVE[chainId].address.toLowerCase()) { methodName = 'zapOutBNB' args = [ pair.liquidityToken.address, @@ -476,8 +475,8 @@ export default function RemoveLiquidity() { const oneCurrencyIsBNB = currencyA === ETHER || currencyB === ETHER const oneCurrencyIsWBNB = Boolean( chainId && - ((currencyA && currencyEquals(WETH[chainId], currencyA)) || - (currencyB && currencyEquals(WETH[chainId], currencyB))), + ((currencyA && currencyEquals(WNATIVE[chainId], currencyA)) || + (currencyB && currencyEquals(WNATIVE[chainId], currencyB))), ) const handleSelectCurrencyA = useCallback( @@ -662,8 +661,8 @@ export default function RemoveLiquidity() { {oneCurrencyIsBNB ? ( {t('Receive WBNB')} @@ -671,8 +670,8 @@ export default function RemoveLiquidity() { ) : oneCurrencyIsWBNB ? ( {t('Receive BNB')} diff --git a/src/views/Swap/hooks/useRefreshBlockNumber.ts b/src/views/Swap/hooks/useRefreshBlockNumber.ts index 171065e74..d803aae86 100644 --- a/src/views/Swap/hooks/useRefreshBlockNumber.ts +++ b/src/views/Swap/hooks/useRefreshBlockNumber.ts @@ -1,3 +1,4 @@ +import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useState, useCallback, useEffect } from 'react' import { useSWRConfig } from 'swr' @@ -11,17 +12,18 @@ export const useRefreshBlockNumber = () => { }, [isLoading]) const { mutate } = useSWRConfig() + const { chainId } = useActiveWeb3React() useEffect(() => { if (!isLoading) return - mutate('blockNumber') + mutate(`blockNumber-${chainId}`) // setTimeout is used to demonstrate the loading // because the real loading state occurs on multicall state // we don't know when the fetch is finished. setTimeout(() => setFetch(false), 500) - }, [mutate, isLoading]) + }, [mutate, isLoading, chainId]) return { refreshBlockNumber, isLoading } } diff --git a/src/views/Swap/index.tsx b/src/views/Swap/index.tsx index 341557db1..7e2658dce 100644 --- a/src/views/Swap/index.tsx +++ b/src/views/Swap/index.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react' import styled from 'styled-components' -import { CurrencyAmount, Token, Trade } from '@pancakeswap/sdk' +import { ChainId, CurrencyAmount, Token, Trade } from '@pancakeswap/sdk' import { computeTradePriceBreakdown, warningSeverity } from 'utils/exchange' import { Button, @@ -19,12 +19,12 @@ import { useIsTransactionUnsupported } from 'hooks/Trades' import UnsupportedCurrencyFooter from 'components/UnsupportedCurrencyFooter' import Footer from 'components/Menu/Footer' import { useRouter } from 'next/router' +import useActiveWeb3React from 'hooks/useActiveWeb3React' import { useTranslation } from 'contexts/Localization' import { EXCHANGE_DOCS_URLS } from 'config/constants' import { BIG_INT_ZERO } from 'config/constants/exchange' import { maxAmountSpend } from 'utils/maxAmountSpend' import shouldShowSwapWarning from 'utils/shouldShowSwapWarning' -import { useWeb3React } from '@web3-react/core' import { useSwapActionHandlers } from 'state/swap/useSwapActionHandlers' import useRefreshBlockNumberID from './hooks/useRefreshBlockNumber' import AddressInputPanel from './components/AddressInputPanel' @@ -90,6 +90,8 @@ const SwitchIconButton = styled(IconButton)` } ` +const CHART_SUPPORT_CHAIN_IDS = [ChainId.BSC] + export default function Swap() { const router = useRouter() const loadedUrlParams = useDefaultsFromURLSearch() @@ -122,7 +124,7 @@ export default function Swap() { return !(token.address in defaultTokens) }) - const { account } = useWeb3React() + const { account, chainId } = useActiveWeb3React() // for expert mode const [isExpertMode] = useExpertModeManager() @@ -212,7 +214,7 @@ export default function Swap() { const noRoute = !route // check whether the user has approved the router on the input token - const [approval, approveCallback] = useApproveCallbackFromTrade(trade, allowedSlippage) + const [approval, approveCallback] = useApproveCallbackFromTrade(trade, allowedSlippage, chainId) // check if user has gone through approval process, used to show two step buttons, reset on token change const [approvalSubmitted, setApprovalSubmitted] = useState(false) @@ -367,10 +369,12 @@ export default function Swap() { } }, [hasAmount, refreshBlockNumber]) + const isChatSupported = useMemo(() => CHART_SUPPORT_CHAIN_IDS.includes(chainId), [chainId]) + return ( - {!isMobile && ( + {!isMobile && isChatSupported && ( )} - - } - isOpen={isChartDisplayed} - setIsOpen={setIsChartDisplayed} - /> + {isChatSupported && ( + + } + isOpen={isChartDisplayed} + setIsOpen={setIsChartDisplayed} + /> + )} diff --git a/src/views/TradingCompetition/helpers.ts b/src/views/TradingCompetition/helpers.ts index 1aba62715..aa60c5171 100644 --- a/src/views/TradingCompetition/helpers.ts +++ b/src/views/TradingCompetition/helpers.ts @@ -3,7 +3,7 @@ import { getBalanceNumber } from 'utils/formatBalance' import { easterPrizes, PrizesConfig } from 'config/constants/trading-competition/prizes' import BigNumber from 'bignumber.js' import useBUSDPrice, { useCakeBusdPrice } from 'hooks/useBUSDPrice' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { multiplyPriceByAmount } from 'utils/prices' export const localiseTradingVolume = (value: number, decimals = 0) => { @@ -31,9 +31,9 @@ export const useFanTokenCompetitionRewards = ({ userPortoRewards: ReactText userSantosRewards: ReactText }) => { - const lazioPriceBUSD = useBUSDPrice(tokens.lazio) - const portoPriceBUSD = useBUSDPrice(tokens.porto) - const santosPriceBUSD = useBUSDPrice(tokens.santos) + const lazioPriceBUSD = useBUSDPrice(bscTokens.lazio) + const portoPriceBUSD = useBUSDPrice(bscTokens.porto) + const santosPriceBUSD = useBUSDPrice(bscTokens.santos) const cakeAsBigNumber = new BigNumber(userCakeRewards as string) const lazioAsBigNumber = new BigNumber(userLazioRewards as string) const portoAsBigNumber = new BigNumber(userPortoRewards as string) @@ -68,7 +68,7 @@ export const useMoboxCompetitionRewards = ({ userCakeRewards: ReactText userMoboxRewards: ReactText }) => { - const moboxPriceBUSD = useBUSDPrice(tokens.mbox) + const moboxPriceBUSD = useBUSDPrice(bscTokens.mbox) const cakeAsBigNumber = new BigNumber(userCakeRewards as string) const moboxAsBigNumber = new BigNumber(userMoboxRewards as string) const cakeBalance = getBalanceNumber(cakeAsBigNumber) @@ -94,17 +94,17 @@ export const useModCompetitionRewards = ({ userCakeRewards: ReactText userDarRewards: ReactText }) => { - const darPriceBUSD = useBUSDPrice(tokens.dar) + const darPriceBUSD = useBUSDPrice(bscTokens.dar) const cakeAsBigNumber = new BigNumber(userCakeRewards as string) const darAsBigNumber = new BigNumber(userDarRewards as string) const cakeBalance = getBalanceNumber(cakeAsBigNumber) - const darBalance = getBalanceNumber(darAsBigNumber, tokens.dar.decimals) + const darBalance = getBalanceNumber(darAsBigNumber, bscTokens.dar.decimals) const cakePriceBusd = useCakeBusdPrice() const dollarValueOfTokensReward = cakePriceBusd && darPriceBUSD ? multiplyPriceByAmount(cakePriceBusd, cakeBalance) + - multiplyPriceByAmount(darPriceBUSD, darBalance, tokens.dar.decimals) + multiplyPriceByAmount(darPriceBUSD, darBalance, bscTokens.dar.decimals) : null return { diff --git a/src/views/Voting/CreateProposal/index.tsx b/src/views/Voting/CreateProposal/index.tsx index f437610df..6de4b76f0 100644 --- a/src/views/Voting/CreateProposal/index.tsx +++ b/src/views/Voting/CreateProposal/index.tsx @@ -20,10 +20,9 @@ import isEmpty from 'lodash/isEmpty' import { useInitialBlock } from 'state/block/hooks' import { SnapshotCommand } from 'state/types' import useToast from 'hooks/useToast' -import useWeb3Provider from 'hooks/useActiveWeb3React' import { getBscScanLink } from 'utils' import truncateHash from 'utils/truncateHash' -import { signMessage } from 'utils/web3React' +import { useSignMessage } from 'utils/web3React' import { useTranslation } from 'contexts/Localization' import Container from 'components/Layout/Container' import { DatePicker, TimePicker, DatePickerPortal } from 'views/Voting/components/DatePicker' @@ -63,7 +62,7 @@ const CreateProposal = () => { const { account } = useWeb3React() const initialBlock = useInitialBlock() const { push } = useRouter() - const { library, connector } = useWeb3Provider() + const { signMessageAsync } = useSignMessage() const { toastSuccess, toastError } = useToast() const [onPresentVoteDetailsModal] = useModal() const { name, body, choices, startDate, startTime, endDate, endTime, snapshot } = state @@ -93,7 +92,7 @@ const CreateProposal = () => { }, }) - const sig = await signMessage(connector, library, account, proposal) + const sig = await signMessageAsync({ message: proposal }) if (sig) { const msg: Message = { address: account, msg: proposal, sig } diff --git a/src/views/Voting/components/CastVoteModal/index.tsx b/src/views/Voting/components/CastVoteModal/index.tsx index 71050011a..515414282 100644 --- a/src/views/Voting/components/CastVoteModal/index.tsx +++ b/src/views/Voting/components/CastVoteModal/index.tsx @@ -3,9 +3,8 @@ import { Box, Modal } from '@pancakeswap/uikit' import { useWeb3React } from '@web3-react/core' import { useTranslation } from 'contexts/Localization' import { SnapshotCommand } from 'state/types' -import { signMessage } from 'utils/web3React' +import { useSignMessage } from 'utils/web3React' import useToast from 'hooks/useToast' -import useWeb3Provider from 'hooks/useActiveWeb3React' import useTheme from 'hooks/useTheme' import { CastVoteModalProps, ConfirmVoteView } from './types' import MainView from './MainView' @@ -19,8 +18,8 @@ const CastVoteModal: React.FC = ({ onSuccess, proposalId, vo const [isPending, setIsPending] = useState(false) const { account } = useWeb3React() const { t } = useTranslation() + const { signMessageAsync } = useSignMessage() const { toastError } = useToast() - const { library, connector } = useWeb3Provider() const { theme } = useTheme() const { isLoading, @@ -60,7 +59,7 @@ const CastVoteModal: React.FC = ({ onSuccess, proposalId, vo }, }) - const sig = await signMessage(connector, library, account, voteMsg) + const sig = await signMessageAsync({ message: voteMsg }) const msg: Message = { address: account, msg: voteMsg, sig } // Save proposal to snapshot diff --git a/src/views/Voting/helpers.ts b/src/views/Voting/helpers.ts index 26c86651e..dc8bdf2fa 100644 --- a/src/views/Voting/helpers.ts +++ b/src/views/Voting/helpers.ts @@ -1,5 +1,5 @@ import { SNAPSHOT_HUB_API } from 'config/constants/endpoints' -import tokens from 'config/constants/tokens' +import { bscTokens } from 'config/constants/tokens' import { Proposal, ProposalState, ProposalType, Vote } from 'state/types' import { ADMINS, PANCAKE_SPACE, SNAPSHOT_VERSION } from './config' import { getScores } from './getScores' @@ -35,7 +35,9 @@ export interface Message { sig: string } -const STRATEGIES = [{ name: 'cake', params: { symbol: 'CAKE', address: tokens.cake.address, decimals: 18, max: 300 } }] +const STRATEGIES = [ + { name: 'cake', params: { symbol: 'CAKE', address: bscTokens.cake.address, decimals: 18, max: 300 } }, +] const NETWORK = '56' /** diff --git a/src/views/Voting/hooks/useGetVotingPower.tsx b/src/views/Voting/hooks/useGetVotingPower.tsx index 29c9b11ca..1709d717f 100644 --- a/src/views/Voting/hooks/useGetVotingPower.tsx +++ b/src/views/Voting/hooks/useGetVotingPower.tsx @@ -1,9 +1,10 @@ +import { ChainId } from '@pancakeswap/sdk' import { useWeb3React } from '@web3-react/core' import { FetchStatus } from 'config/constants/types' import useSWRImmutable from 'swr/immutable' import { getAddress } from 'utils/addressHelpers' import { getActivePools } from 'utils/calls' -import { simpleRpcProvider } from 'utils/providers' +import { bscRpcProvider } from 'utils/providers' import { getVotingPower } from '../helpers' interface State { @@ -21,9 +22,9 @@ const useGetVotingPower = (block?: number, isActive = true): State & { isLoading const { data, status, error } = useSWRImmutable( account && isActive ? [account, block, 'votingPower'] : null, async () => { - const blockNumber = block || (await simpleRpcProvider.getBlockNumber()) + const blockNumber = block || (await bscRpcProvider.getBlockNumber()) const eligiblePools = await getActivePools(blockNumber) - const poolAddresses = eligiblePools.map(({ contractAddress }) => getAddress(contractAddress)) + const poolAddresses = eligiblePools.map(({ contractAddress }) => getAddress(contractAddress, ChainId.BSC)) const { cakeBalance, cakeBnbLpBalance, cakePoolBalance, total, poolsBalance, cakeVaultBalance, ifoPoolBalance } = await getVotingPower(account, poolAddresses, blockNumber) return { diff --git a/tsconfig.json b/tsconfig.json index a1cb3ac34..381516e13 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,10 @@ "noImplicitAny": false, "noFallthroughCasesInSwitch": true, "downlevelIteration": true, - "target": "es5" + "target": "es5", + "paths": { + "@pancakeswap/sdk": ["../packages/swap-sdk/src/index.ts"] + } }, "exclude": ["node_modules", "cypress", "/apps/*"], "include": ["next-env.d.ts", "./src/**/*.ts", "./src/**/*.tsx"] diff --git a/yarn.lock b/yarn.lock index 199513640..6426a1aeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1615,6 +1615,21 @@ "@ethersproject/properties" "^5.5.0" "@ethersproject/strings" "^5.5.0" +"@ethersproject/abi@^5.6.3": + version "5.6.4" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.6.4.tgz#f6e01b6ed391a505932698ecc0d9e7a99ee60362" + integrity sha512-TTeZUlCeIHG6527/2goZA6gW5F8Emoc7MrZDC7hhP84aRGvW3TEdTnZR08Ls88YXM1m2SuK42Osw/jSi3uO8gg== + dependencies: + "@ethersproject/address" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/hash" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/strings" "^5.6.1" + "@ethersproject/abstract-provider@5.5.1", "@ethersproject/abstract-provider@^5.5.0": version "5.5.1" resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.5.1.tgz#2f1f6e8a3ab7d378d8ad0b5718460f85649710c5" @@ -1628,6 +1643,19 @@ "@ethersproject/transactions" "^5.5.0" "@ethersproject/web" "^5.5.0" +"@ethersproject/abstract-provider@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.6.1.tgz#02ddce150785caf0c77fe036a0ebfcee61878c59" + integrity sha512-BxlIgogYJtp1FS8Muvj8YfdClk3unZH0vRMVX791Z9INBNT/kuACZ9GzaY1Y4yFq+YSy6/w4gzj3HCRKrK9hsQ== + dependencies: + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/networks" "^5.6.3" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/transactions" "^5.6.2" + "@ethersproject/web" "^5.6.1" + "@ethersproject/abstract-signer@5.5.0", "@ethersproject/abstract-signer@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.5.0.tgz#590ff6693370c60ae376bf1c7ada59eb2a8dd08d" @@ -1639,6 +1667,17 @@ "@ethersproject/logger" "^5.5.0" "@ethersproject/properties" "^5.5.0" +"@ethersproject/abstract-signer@^5.6.2": + version "5.6.2" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.6.2.tgz#491f07fc2cbd5da258f46ec539664713950b0b33" + integrity sha512-n1r6lttFBG0t2vNiI3HoWaS/KdOt8xyDjzlP2cuevlWLG6EX0OwcKLyG/Kp/cuwNxdy/ous+R/DEMdTUwWQIjQ== + dependencies: + "@ethersproject/abstract-provider" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/address@5.5.0", "@ethersproject/address@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.5.0.tgz#bcc6f576a553f21f3dd7ba17248f81b473c9c78f" @@ -1650,6 +1689,17 @@ "@ethersproject/logger" "^5.5.0" "@ethersproject/rlp" "^5.5.0" +"@ethersproject/address@^5.0.2", "@ethersproject/address@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.6.1.tgz#ab57818d9aefee919c5721d28cd31fd95eff413d" + integrity sha512-uOgF0kS5MJv9ZvCz7x6T2EXJSzotiybApn4XlOgoTX0xdtyVIJ7pF+6cGPxiEq/dpBiTfMiw7Yc81JcwhSYA0Q== + dependencies: + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/rlp" "^5.6.1" + "@ethersproject/base64@5.5.0", "@ethersproject/base64@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.5.0.tgz#881e8544e47ed976930836986e5eb8fab259c090" @@ -1657,6 +1707,13 @@ dependencies: "@ethersproject/bytes" "^5.5.0" +"@ethersproject/base64@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.6.1.tgz#2c40d8a0310c9d1606c2c37ae3092634b41d87cb" + integrity sha512-qB76rjop6a0RIYYMiB4Eh/8n+Hxu2NIZm8S/Q7kNo5pmZfXhHGHmS4MinUainiBC54SCyRnwzL+KZjj8zbsSsw== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/basex@5.5.0", "@ethersproject/basex@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.5.0.tgz#e40a53ae6d6b09ab4d977bd037010d4bed21b4d3" @@ -1665,6 +1722,14 @@ "@ethersproject/bytes" "^5.5.0" "@ethersproject/properties" "^5.5.0" +"@ethersproject/basex@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.6.1.tgz#badbb2f1d4a6f52ce41c9064f01eab19cc4c5305" + integrity sha512-a52MkVz4vuBXR06nvflPMotld1FJWSj2QT0985v7P/emPZO00PucFAkbcmq2vpVU7Ts7umKiSI6SppiLykVWsA== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/bignumber@5.5.0", "@ethersproject/bignumber@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.5.0.tgz#875b143f04a216f4f8b96245bde942d42d279527" @@ -1674,6 +1739,15 @@ "@ethersproject/logger" "^5.5.0" bn.js "^4.11.9" +"@ethersproject/bignumber@^5.6.2": + version "5.6.2" + resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.6.2.tgz#72a0717d6163fab44c47bcc82e0c550ac0315d66" + integrity sha512-v7+EEUbhGqT3XJ9LMPsKvXYHFc8eHxTowFCG/HgJErmq4XHJ2WR7aeyICg3uTOAQ7Icn0GFHAohXEhxQHq4Ubw== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + bn.js "^5.2.1" + "@ethersproject/bytes@5.5.0", "@ethersproject/bytes@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.5.0.tgz#cb11c526de657e7b45d2e0f0246fb3b9d29a601c" @@ -1681,6 +1755,13 @@ dependencies: "@ethersproject/logger" "^5.5.0" +"@ethersproject/bytes@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.6.1.tgz#24f916e411f82a8a60412344bf4a813b917eefe7" + integrity sha512-NwQt7cKn5+ZE4uDn+X5RAXLp46E1chXoaMmrxAyA0rblpxz8t58lVkrHXoRIn0lz1joQElQ8410GqhTqMOwc6g== + dependencies: + "@ethersproject/logger" "^5.6.0" + "@ethersproject/constants@5.5.0", "@ethersproject/constants@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.5.0.tgz#d2a2cd7d94bd1d58377d1d66c4f53c9be4d0a45e" @@ -1688,6 +1769,13 @@ dependencies: "@ethersproject/bignumber" "^5.5.0" +"@ethersproject/constants@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.6.1.tgz#e2e974cac160dd101cf79fdf879d7d18e8cb1370" + integrity sha512-QSq9WVnZbxXYFftrjSjZDUshp6/eKp6qrtdBtUCm0QxCV5z1fG/w3kdlcsjMCQuQHUnAclKoK7XpXMezhRDOLg== + dependencies: + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/contracts@5.5.0", "@ethersproject/contracts@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.5.0.tgz#b735260d4bd61283a670a82d5275e2a38892c197" @@ -1704,6 +1792,22 @@ "@ethersproject/properties" "^5.5.0" "@ethersproject/transactions" "^5.5.0" +"@ethersproject/contracts@^5.0.2": + version "5.6.2" + resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.6.2.tgz#20b52e69ebc1b74274ff8e3d4e508de971c287bc" + integrity sha512-hguUA57BIKi6WY0kHvZp6PwPlWF87MCeB4B7Z7AbUpTxfFXFdn/3b0GmjZPagIHS+3yhcBJDnuEfU4Xz+Ks/8g== + dependencies: + "@ethersproject/abi" "^5.6.3" + "@ethersproject/abstract-provider" "^5.6.1" + "@ethersproject/abstract-signer" "^5.6.2" + "@ethersproject/address" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/transactions" "^5.6.2" + "@ethersproject/experimental@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/experimental/-/experimental-5.5.0.tgz#3fdf8d51112c1074f401ef3c6c9e57f8a3cf12e3" @@ -1727,6 +1831,20 @@ "@ethersproject/properties" "^5.5.0" "@ethersproject/strings" "^5.5.0" +"@ethersproject/hash@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.6.1.tgz#224572ea4de257f05b4abf8ae58b03a67e99b0f4" + integrity sha512-L1xAHurbaxG8VVul4ankNX5HgQ8PNCTrnVXEiFnE9xoRnaUcgfD12tZINtDinSllxPLCtGwguQxJ5E6keE84pA== + dependencies: + "@ethersproject/abstract-signer" "^5.6.2" + "@ethersproject/address" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/strings" "^5.6.1" + "@ethersproject/hdnode@5.5.0", "@ethersproject/hdnode@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/hdnode/-/hdnode-5.5.0.tgz#4a04e28f41c546f7c978528ea1575206a200ddf6" @@ -1772,11 +1890,24 @@ "@ethersproject/bytes" "^5.5.0" js-sha3 "0.8.0" +"@ethersproject/keccak256@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.6.1.tgz#b867167c9b50ba1b1a92bccdd4f2d6bd168a91cc" + integrity sha512-bB7DQHCTRDooZZdL3lk9wpL0+XuG3XLGHLh3cePnybsO3V0rdCAOQGpn/0R3aODmnTOOkCATJiD2hnL+5bwthA== + dependencies: + "@ethersproject/bytes" "^5.6.1" + js-sha3 "0.8.0" + "@ethersproject/logger@5.5.0", "@ethersproject/logger@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.5.0.tgz#0c2caebeff98e10aefa5aef27d7441c7fd18cf5d" integrity sha512-rIY/6WPm7T8n3qS2vuHTUBPdXHl+rGxWxW5okDfo9J4Z0+gRRZT0msvUdIJkE4/HS29GUMziwGaaKO2bWONBrg== +"@ethersproject/logger@^5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.6.0.tgz#d7db1bfcc22fd2e4ab574cba0bb6ad779a9a3e7a" + integrity sha512-BiBWllUROH9w+P21RzoxJKzqoqpkyM1pRnEKG69bulE9TSQD8SAIvTQqIMZmmCO8pUNkgLP1wndX1gKghSpBmg== + "@ethersproject/networks@5.5.2", "@ethersproject/networks@^5.5.0": version "5.5.2" resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.5.2.tgz#784c8b1283cd2a931114ab428dae1bd00c07630b" @@ -1784,6 +1915,13 @@ dependencies: "@ethersproject/logger" "^5.5.0" +"@ethersproject/networks@^5.0.2", "@ethersproject/networks@^5.6.3": + version "5.6.4" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.6.4.tgz#51296d8fec59e9627554f5a8a9c7791248c8dc07" + integrity sha512-KShHeHPahHI2UlWdtDMn2lJETcbtaJge4k7XSjDR9h79QTd6yQJmv6Cp2ZA4JdqWnhszAOLSuJEd9C0PRw7hSQ== + dependencies: + "@ethersproject/logger" "^5.6.0" + "@ethersproject/pbkdf2@5.5.0", "@ethersproject/pbkdf2@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.5.0.tgz#e25032cdf02f31505d47afbf9c3e000d95c4a050" @@ -1799,6 +1937,13 @@ dependencies: "@ethersproject/logger" "^5.5.0" +"@ethersproject/properties@^5.6.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.6.0.tgz#38904651713bc6bdd5bdd1b0a4287ecda920fa04" + integrity sha512-szoOkHskajKePTJSZ46uHUWWkbv7TzP2ypdEK6jGMqJaEt2sb0jCgfBo0gH0m2HBpRixMuJ6TBRaQCF7a9DoCg== + dependencies: + "@ethersproject/logger" "^5.6.0" + "@ethersproject/providers@5.5.3": version "5.5.3" resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.5.3.tgz#56c2b070542ac44eb5de2ed3cf6784acd60a3130" @@ -1824,6 +1969,32 @@ bech32 "1.1.4" ws "7.4.6" +"@ethersproject/providers@^5.0.5": + version "5.6.8" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.6.8.tgz#22e6c57be215ba5545d3a46cf759d265bb4e879d" + integrity sha512-Wf+CseT/iOJjrGtAOf3ck9zS7AgPmr2fZ3N97r4+YXN3mBePTG2/bJ8DApl9mVwYL+RpYbNxMEkEp4mPGdwG/w== + dependencies: + "@ethersproject/abstract-provider" "^5.6.1" + "@ethersproject/abstract-signer" "^5.6.2" + "@ethersproject/address" "^5.6.1" + "@ethersproject/base64" "^5.6.1" + "@ethersproject/basex" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/hash" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/networks" "^5.6.3" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/random" "^5.6.1" + "@ethersproject/rlp" "^5.6.1" + "@ethersproject/sha2" "^5.6.1" + "@ethersproject/strings" "^5.6.1" + "@ethersproject/transactions" "^5.6.2" + "@ethersproject/web" "^5.6.1" + bech32 "1.1.4" + ws "7.4.6" + "@ethersproject/providers@^5.5.2": version "5.5.2" resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.5.2.tgz#131ccf52dc17afd0ab69ed444b8c0e3a27297d99" @@ -1857,6 +2028,14 @@ "@ethersproject/bytes" "^5.5.0" "@ethersproject/logger" "^5.5.0" +"@ethersproject/random@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.6.1.tgz#66915943981bcd3e11bbd43733f5c3ba5a790255" + integrity sha512-/wtPNHwbmng+5yi3fkipA8YBT59DdkGRoC2vWk09Dci/q5DlgnMkhIycjHlavrvrjJBkFjO/ueLyT+aUDfc4lA== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/rlp@5.5.0", "@ethersproject/rlp@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.5.0.tgz#530f4f608f9ca9d4f89c24ab95db58ab56ab99a0" @@ -1865,6 +2044,14 @@ "@ethersproject/bytes" "^5.5.0" "@ethersproject/logger" "^5.5.0" +"@ethersproject/rlp@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.6.1.tgz#df8311e6f9f24dcb03d59a2bac457a28a4fe2bd8" + integrity sha512-uYjmcZx+DKlFUk7a5/W9aQVaoEC7+1MOBgNtvNg13+RnuUwT4F0zTovC0tmay5SmRslb29V1B7Y5KCri46WhuQ== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/sha2@5.5.0", "@ethersproject/sha2@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.5.0.tgz#a40a054c61f98fd9eee99af2c3cc6ff57ec24db7" @@ -1874,6 +2061,15 @@ "@ethersproject/logger" "^5.5.0" hash.js "1.1.7" +"@ethersproject/sha2@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.6.1.tgz#211f14d3f5da5301c8972a8827770b6fd3e51656" + integrity sha512-5K2GyqcW7G4Yo3uenHegbXRPDgARpWUiXc6RiF7b6i/HXUoWlb7uCARh7BAHg7/qT/Q5ydofNwiZcim9qpjB6g== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + hash.js "1.1.7" + "@ethersproject/signing-key@5.5.0", "@ethersproject/signing-key@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.5.0.tgz#2aa37169ce7e01e3e80f2c14325f624c29cedbe0" @@ -1886,6 +2082,18 @@ elliptic "6.5.4" hash.js "1.1.7" +"@ethersproject/signing-key@^5.6.2": + version "5.6.2" + resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.6.2.tgz#8a51b111e4d62e5a62aee1da1e088d12de0614a3" + integrity sha512-jVbu0RuP7EFpw82vHcL+GP35+KaNruVAZM90GxgQnGqB6crhBqW/ozBfFvdeImtmb4qPko0uxXjn8l9jpn0cwQ== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + bn.js "^5.2.1" + elliptic "6.5.4" + hash.js "1.1.7" + "@ethersproject/solidity@5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.5.0.tgz#2662eb3e5da471b85a20531e420054278362f93f" @@ -1898,6 +2106,18 @@ "@ethersproject/sha2" "^5.5.0" "@ethersproject/strings" "^5.5.0" +"@ethersproject/solidity@^5.0.2": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.6.1.tgz#5845e71182c66d32e6ec5eefd041fca091a473e2" + integrity sha512-KWqVLkUUoLBfL1iwdzUVlkNqAUIFMpbbeH0rgCfKmJp0vFtY4AsaN91gHKo9ZZLkC4UOm3cI3BmMV4N53BOq4g== + dependencies: + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/sha2" "^5.6.1" + "@ethersproject/strings" "^5.6.1" + "@ethersproject/strings@5.5.0", "@ethersproject/strings@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.5.0.tgz#e6784d00ec6c57710755699003bc747e98c5d549" @@ -1907,6 +2127,15 @@ "@ethersproject/constants" "^5.5.0" "@ethersproject/logger" "^5.5.0" +"@ethersproject/strings@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.6.1.tgz#dbc1b7f901db822b5cafd4ebf01ca93c373f8952" + integrity sha512-2X1Lgk6Jyfg26MUnsHiT456U9ijxKUybz8IM1Vih+NJxYtXhmvKBcHOmvGqpFSVJ0nQ4ZCoIViR8XlRw1v/+Cw== + dependencies: + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/transactions@5.5.0", "@ethersproject/transactions@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.5.0.tgz#7e9bf72e97bcdf69db34fe0d59e2f4203c7a2908" @@ -1922,6 +2151,21 @@ "@ethersproject/rlp" "^5.5.0" "@ethersproject/signing-key" "^5.5.0" +"@ethersproject/transactions@^5.6.2": + version "5.6.2" + resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.6.2.tgz#793a774c01ced9fe7073985bb95a4b4e57a6370b" + integrity sha512-BuV63IRPHmJvthNkkt9G70Ullx6AcM+SDc+a8Aw/8Yew6YwT51TcBKEp1P4oOQ/bP25I18JJr7rcFRgFtU9B2Q== + dependencies: + "@ethersproject/address" "^5.6.1" + "@ethersproject/bignumber" "^5.6.2" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/constants" "^5.6.1" + "@ethersproject/keccak256" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/rlp" "^5.6.1" + "@ethersproject/signing-key" "^5.6.2" + "@ethersproject/units@5.5.0", "@ethersproject/units@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.5.0.tgz#104d02db5b5dc42cc672cc4587bafb87a95ee45e" @@ -1963,6 +2207,17 @@ "@ethersproject/properties" "^5.5.0" "@ethersproject/strings" "^5.5.0" +"@ethersproject/web@^5.6.1": + version "5.6.1" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.6.1.tgz#6e2bd3ebadd033e6fe57d072db2b69ad2c9bdf5d" + integrity sha512-/vSyzaQlNXkO1WV+RneYKqCJwualcUdx/Z3gseVovZP0wIlOFcCE1hkRhKBH8ImKbGQbMl9EAAyJFrJu7V0aqA== + dependencies: + "@ethersproject/base64" "^5.6.1" + "@ethersproject/bytes" "^5.6.1" + "@ethersproject/logger" "^5.6.0" + "@ethersproject/properties" "^5.6.0" + "@ethersproject/strings" "^5.6.1" + "@ethersproject/wordlists@5.5.0", "@ethersproject/wordlists@^5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.5.0.tgz#aac74963aa43e643638e5172353d931b347d584f" @@ -2091,6 +2346,13 @@ slash "^3.0.0" strip-ansi "^6.0.0" +"@jest/create-cache-key-function@^27.4.2": + version "27.5.1" + resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-27.5.1.tgz#7448fae15602ea95c828f5eceed35c202a820b31" + integrity sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ== + dependencies: + "@jest/types" "^27.5.1" + "@jest/environment@^27.5.1": version "27.5.1" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.5.1.tgz#d7425820511fe7158abbecc010140c3fd3be9c74" @@ -2224,6 +2486,15 @@ source-map "^0.6.1" write-file-atomic "^3.0.0" +"@jest/types@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-24.9.0.tgz#63cb26cb7500d069e5a389441a7c6ab5e909fc59" + integrity sha512-XKK7ze1apu5JWQ5eZjHITP66AX+QsLlbaJRBGYr8pNzwcAE2JVkwnf0yqjHTsDRcjR0mujy/NmZMXw5kl+kGBw== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^1.1.1" + "@types/yargs" "^13.0.0" + "@jest/types@^26.6.2": version "26.6.2" resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e" @@ -3466,18 +3737,6 @@ dependencies: "@octokit/openapi-types" "^11.2.0" -"@pancakeswap/sdk@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@pancakeswap/sdk/-/sdk-2.4.5.tgz#783c02efc7ca89d2297b0b07040639d90c3e610d" - integrity sha512-qfHOPGXitDQ5y1dmYloe6UQe/0Ki0enow4MLtr5W49Jl7ZXr8oB6XV7usYtT63R7vqLSKY83rd8Wyw18vxP7dA== - dependencies: - big.js "^5.2.2" - decimal.js-light "^2.5.0" - jsbi "^3.1.4" - tiny-invariant "^1.1.0" - tiny-warning "^1.0.3" - toformat "^2.0.0" - "@pedrouid/environment@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@pedrouid/environment/-/environment-1.0.1.tgz#858f0f8a057340e0b250398b75ead77d6f4342ec" @@ -4717,6 +4976,90 @@ dependencies: "@babel/core" ">=7.9.0" +"@swc/core-android-arm-eabi@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.218.tgz#017792272e70a0511d7df3397a31d73c6ef37b40" + integrity sha512-Q/uLCh262t3xxNzhCz+ZW9t+g2nWd0gZZO4jMYFWJs7ilKVNsBfRtfnNGGACHzkVuWLNDIWtAS2PSNodl7VUHQ== + +"@swc/core-android-arm64@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.218.tgz#ee1b6cd7281d9bd0f26d5d24843addf09365c137" + integrity sha512-dy+8lUHUcyrkfPcl7azEQ4M44duRo1Uibz1E5/tltXCGoR6tu2ZN2VkqEKgA2a9XR3UD8/x4lv2r5evwJWy+uQ== + +"@swc/core-darwin-arm64@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.218.tgz#d73f6eedf0aac4ad117e67227d65d65c57657858" + integrity sha512-aTpFjWio8G0oukN76VtXCBPtFzH0PXIQ+1dFjGGkzrBcU5suztCCbhPBGhKRoWp3NJBwfPDwwWzmG+ddXrVAKg== + +"@swc/core-darwin-x64@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.218.tgz#a872c618727ceac8780539b5fa8aa45ae600d362" + integrity sha512-H3w/gNzROE6gVPZCAg5qvvPihzlg88Yi7HWb/mowfpNqH9/iJ8XMdwqJyovnfUeUXsuJQBFv6uXv/ri7qhGMHA== + +"@swc/core-freebsd-x64@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.218.tgz#6abc75e409739cad2ed9d57c1c741e8e5759794c" + integrity sha512-kkch07yCSlpUrSMp0FZPWtMHJjh3lfHiwp7JYNf6CUl5xXlgT19NeomPYq31dbTzPV2VnE7TVVlAawIjuuOH4g== + +"@swc/core-linux-arm-gnueabihf@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.218.tgz#a1a1bb172632082766770e47426df606c828d28c" + integrity sha512-vwEgvtD9f/+0HFxYD5q4sd8SG6zd0cxm17cwRGZ6jWh/d4Ninjht3CpDGE1ffh9nJ+X3Mb/7rjU/kTgWFz5qfg== + +"@swc/core-linux-arm64-gnu@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.218.tgz#4d3325cd35016dd5ec389084bd5c304348002b15" + integrity sha512-g5PQI6COUHV7x7tyaZQn6jXWtOLXXNIEQK1HS5/e+6kqqsM2NsndE9bjLhoH1EQuXiN2eUjAR/ZDOFAg102aRw== + +"@swc/core-linux-arm64-musl@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.218.tgz#8abab2fe12bb6a7687ff3bbd6030fcc728ed007d" + integrity sha512-IETYHB6H01NmVmlw+Ng8nkjdFBv1exGQRR74GAnHis1bVx1Uq14hREIF6XT3I1Aj26nRwlGkIYQuEKnFO5/j3Q== + +"@swc/core-linux-x64-gnu@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.218.tgz#39227c15018d9b5253e7679bc8bbe3fd7ed109cd" + integrity sha512-PK39Zg4/YZbfchQRw77iVfB7Qat7QaK58sQt8enH39CUMXlJ+GSfC0Fqw2mtZ12sFGwmsGrK9yBy3ZVoOws5Ng== + +"@swc/core-linux-x64-musl@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.218.tgz#d661bfc6a9f0c35979c0e608777355222092e534" + integrity sha512-SNjrzORJYiKTSmFbaBkKZAf5B/PszwoZoFZOcd86AG192zsvQBSvKjQzMjT5rDZxB+sOnhRE7wH/bvqxZishQQ== + +"@swc/core-win32-arm64-msvc@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.218.tgz#ea94260b36010d67f529d2f73c99e7d338a98711" + integrity sha512-lVXFWkYl+w8+deq9mgGsfvSY5Gr1RRjFgqZ+0wMZgyaonfx7jNn3TILUwc7egumEwxK0anNriVZCyKfcO3ZIjA== + +"@swc/core-win32-ia32-msvc@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.218.tgz#b5b5fbbe17680e0e1626d974ac2ace2866da7639" + integrity sha512-jgP+NZsHUh9Cp8PcXznnkpJTW3hPDLUgsXI0NKfE+8+Xvc6hALHxl6K46IyPYU67FfFlegYcBSNkOgpc85gk0A== + +"@swc/core-win32-x64-msvc@1.2.218": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.218.tgz#9f6ba50cac6e3322d844cc24418c7b0ab08f7e0e" + integrity sha512-XYLjX00KV4ft324Q3QDkw61xHkoN7EKkVvIpb0wXaf6wVshwU+BCDyPw2CSg4PQecNP8QGgMRQf9QM7xNtEM7A== + +"@swc/core@^1.2.215": + version "1.2.218" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.218.tgz#3bc7532621f491bf920d103a4a0433ac7df9d390" + integrity sha512-wzXTeBUi3YAHr305lCo1tlxRj5Zpk7hu6rmulngH06NgrH7fS6bj8IaR7K2QPZ4ZZ4U+TGS2tOKbXBmqeMRUtg== + optionalDependencies: + "@swc/core-android-arm-eabi" "1.2.218" + "@swc/core-android-arm64" "1.2.218" + "@swc/core-darwin-arm64" "1.2.218" + "@swc/core-darwin-x64" "1.2.218" + "@swc/core-freebsd-x64" "1.2.218" + "@swc/core-linux-arm-gnueabihf" "1.2.218" + "@swc/core-linux-arm64-gnu" "1.2.218" + "@swc/core-linux-arm64-musl" "1.2.218" + "@swc/core-linux-x64-gnu" "1.2.218" + "@swc/core-linux-x64-musl" "1.2.218" + "@swc/core-win32-arm64-msvc" "1.2.218" + "@swc/core-win32-ia32-msvc" "1.2.218" + "@swc/core-win32-x64-msvc" "1.2.218" + "@swc/helpers@0.4.2": version "0.4.2" resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.2.tgz#ed1f6997ffbc22396665d9ba74e2a5c0a2d782f8" @@ -4724,6 +5067,13 @@ dependencies: tslib "^2.4.0" +"@swc/jest@^0.2.21": + version "0.2.22" + resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.22.tgz#70d02ac648c21a442016d7a0aa485577335a4c9a" + integrity sha512-PIUIk9IdB1oAVfF9zNIfYoMBoEhahrrSvyryFANas7swC1cF0L5HR0f9X4qfet46oyCHCBtNcSpN0XJEOFIKlw== + dependencies: + "@jest/create-cache-key-function" "^27.4.2" + "@testing-library/dom@^8.0.0": version "8.11.3" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.11.3.tgz#38fd63cbfe14557021e88982d931e33fb7c1a808" @@ -4844,6 +5194,11 @@ dependencies: "@babel/types" "^7.3.0" +"@types/big.js@^4.0.5": + version "4.0.5" + resolved "https://registry.yarnpkg.com/@types/big.js/-/big.js-4.0.5.tgz#62c61697646269e39191f24e55e8272f05f21fc0" + integrity sha512-D9KFrAt05FDSqLo7PU9TDHfDgkarlwdkuwFsg7Zm4xl62tTNaz+zN+Tkcdx2wGLBbSMf8BnoMhOVeUGUaJfLKg== + "@types/bn.js@^4.11.3", "@types/bn.js@^4.11.5": version "4.11.6" resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" @@ -4962,6 +5317,14 @@ dependencies: "@types/istanbul-lib-coverage" "*" +"@types/istanbul-reports@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz#e875cc689e47bce549ec81f3df5e6f6f11cfaeb2" + integrity sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw== + dependencies: + "@types/istanbul-lib-coverage" "*" + "@types/istanbul-lib-report" "*" + "@types/istanbul-reports@^3.0.0": version "3.0.1" resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz#9153fe98bba2bd565a63add9436d6f0d7f8468ff" @@ -4977,6 +5340,13 @@ jest-matcher-utils "^27.0.0" pretty-format "^27.0.0" +"@types/jest@^24.0.25": + version "24.9.1" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.9.1.tgz#02baf9573c78f1b9974a5f36778b366aa77bd534" + integrity sha512-Fb38HkXSVA4L8fGKEZ6le5bB8r6MRWlOCZbVuWZcmOMSCd2wCYOwN1ibj8daIoV9naq7aaOZjrLCoCMptKU/4Q== + dependencies: + jest-diff "^24.3.0" + "@types/jest@^26.0.23": version "26.0.24" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.24.tgz#943d11976b16739185913a1936e0de0c4a7d595a" @@ -5349,6 +5719,13 @@ resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.1.tgz#3b9ce2489919d9e4fea439b76916abc34b2df129" integrity sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw== +"@types/yargs@^13.0.0": + version "13.0.12" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-13.0.12.tgz#d895a88c703b78af0465a9de88aa92c61430b092" + integrity sha512-qCxJE1qgz2y0hA4pIxjBR+PelCH0U5CK1XJXFwCNqfmliatKp47UCXXE9Dyk1OXBDLvsCF57TqQEJaeLfDYEOQ== + dependencies: + "@types/yargs-parser" "*" + "@types/yargs@^15.0.0": version "15.0.14" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.14.tgz#26d821ddb89e70492160b66d10a0eb6df8f6fb06" @@ -6425,6 +6802,11 @@ ansi-regex@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= +ansi-regex@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== + ansi-regex@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" @@ -6471,6 +6853,11 @@ ansi-to-html@^0.6.11: dependencies: entities "^2.0.0" +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -7043,6 +7430,11 @@ babel-plugin-syntax-jsx@^6.18.0: resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946" integrity sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY= +babel-plugin-transform-jsbi-to-bigint@^1.3.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-jsbi-to-bigint/-/babel-plugin-transform-jsbi-to-bigint-1.4.0.tgz#04db5036c7821916c248b90ded792a1272bc9c8d" + integrity sha512-59f6ClwQBY/SKMVwKV/xoAqH/gnyZ6C5gSSPsEUCLPvvZULCDSE5Y3T62wjNTbpBcFzh0ReYz2mIe3u44mW9UQ== + babel-preset-current-node-syntax@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz#b4399239b89b2a011f9ddbe3e4f401fc40cff73b" @@ -7217,6 +7609,11 @@ bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== +bn.js@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" + integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== + body-parser@1.19.2: version "1.19.2" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.2.tgz#4714ccd9c157d44797b8b5607d72c0b89952f26e" @@ -7544,6 +7941,13 @@ builtins@^1.0.3: resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" integrity sha1-y5T662HIaWRR2zZTThQi+U8K7og= +bundle-require@^3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/bundle-require/-/bundle-require-3.0.4.tgz#2b52ba77d99c0a586b5854cd21d36954e63cc110" + integrity sha512-VXG6epB1yrLAvWVQpl92qF347/UXmncQj7J3U8kZEbdVZ1ZkQyr4hYeL/9RvcE8vVVdp53dY78Fd/3pqfRqI1A== + dependencies: + load-tsconfig "^0.2.0" + byline@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/byline/-/byline-5.0.0.tgz#741c5216468eadc457b03410118ad77de8c1ddb1" @@ -7582,6 +7986,11 @@ c8@^7.6.0: yargs "^16.2.0" yargs-parser "^20.2.9" +cac@^6.7.12: + version "6.7.12" + resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.12.tgz#6fb5ea2ff50bd01490dbda497f4ae75a99415193" + integrity sha512-rM7E2ygtMkJqD9c7WnFU6fruFcN3xe4FM5yUmgxhZzIKJk4uHl9U/fhwdajGFQbQuv43FAUo1Fe8gX/oIKDeSA== + cacache@^12.0.2: version "12.0.4" resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c" @@ -7857,7 +8266,7 @@ chokidar@^2.1.8: optionalDependencies: fsevents "^1.2.7" -chokidar@^3.4.1, chokidar@^3.4.2: +chokidar@^3.4.1, chokidar@^3.4.2, chokidar@^3.5.1: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -8207,7 +8616,7 @@ commander@^2.19.0, commander@^2.20.0, commander@^2.20.3: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^4.1.1: +commander@^4.0.0, commander@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== @@ -9193,6 +9602,11 @@ dezalgo@^1.0.0: asap "^2.0.0" wrappy "1" +diff-sequences@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5" + integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew== + diff-sequences@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" @@ -9801,7 +10215,7 @@ esbuild-windows-arm64@0.14.49: resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.49.tgz#d83c03ff6436caf3262347cfa7e16b0a8049fae7" integrity sha512-v+HYNAXzuANrCbbLFJ5nmO3m5y2PGZWLe3uloAkLt87aXiO2mZr3BTmacZdjwNkNEHuH3bNtN8cak+mzVjVPfA== -esbuild@^0.14.47: +esbuild@^0.14.25, esbuild@^0.14.47: version "0.14.49" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.49.tgz#b82834760eba2ddc17b44f05cfcc0aaca2bae492" integrity sha512-/TlVHhOaq7Yz8N1OJrjqM3Auzo5wjvHFLk+T8pIue+fhnhIMpfAzsG6PLVMbFveVxqD2WOp3QHei+52IMUNmCw== @@ -11595,6 +12009,18 @@ glob-to-regexp@^0.4.1: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== +glob@7.1.6: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + glob@7.1.7: version "7.1.7" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" @@ -11688,7 +12114,7 @@ globalthis@^1.0.0: dependencies: define-properties "^1.1.3" -globby@^11.0.2, globby@^11.0.4, globby@^11.1.0: +globby@^11.0.2, globby@^11.0.3, globby@^11.0.4, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -13115,6 +13541,16 @@ jest-config@^27.5.1: slash "^3.0.0" strip-json-comments "^3.1.1" +jest-diff@^24.3.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.9.0.tgz#931b7d0d5778a1baf7452cb816e325e3724055da" + integrity sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ== + dependencies: + chalk "^2.0.1" + diff-sequences "^24.9.0" + jest-get-type "^24.9.0" + pretty-format "^24.9.0" + jest-diff@^26.0.0: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394" @@ -13178,6 +13614,11 @@ jest-environment-node@^27.5.1: jest-mock "^27.5.1" jest-util "^27.5.1" +jest-get-type@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-24.9.0.tgz#1684a0c8a50f2e4901b6644ae861f579eed2ef0e" + integrity sha512-lUseMzAley4LhIcpSP9Jf+fTrQ4a1yHQwLNeeVa2cEmbCGeoZAtYPOIv8JaxLD/sUpKxetKGP+gsHl8f8TSj8Q== + jest-get-type@^26.3.0: version "26.3.0" resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-26.3.0.tgz#e97dc3c3f53c2b406ca7afaed4493b1d099199e0" @@ -13526,6 +13967,11 @@ joi@^17.4.0: "@sideway/formula" "^3.0.0" "@sideway/pinpoint" "^2.0.0" +joycon@^3.0.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" + integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== + js-cookie@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.1.tgz#9e39b4c6c2f56563708d7d31f6f5f21873a92414" @@ -14054,6 +14500,11 @@ lilconfig@2.0.4: resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" integrity sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA== +lilconfig@^2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.6.tgz#32a384558bd58af3d4c6e077dd1ad1d397bc69d4" + integrity sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg== + lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" @@ -14137,6 +14588,11 @@ load-json-file@^6.2.0: strip-bom "^4.0.0" type-fest "^0.6.0" +load-tsconfig@^0.2.0: + version "0.2.3" + resolved "https://registry.yarnpkg.com/load-tsconfig/-/load-tsconfig-0.2.3.tgz#08af3e7744943caab0c75f8af7f1703639c3ef1f" + integrity sha512-iyT2MXws+dc2Wi6o3grCFtGXpeMvHmJqS27sMPGtV2eUu4PeFnG+33I8BlFK1t1NWMjOpcx9bridn5yxLDX2gQ== + loader-runner@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" @@ -14252,6 +14708,11 @@ lodash.once@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== + lodash.template@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" @@ -15218,6 +15679,15 @@ mute-stream@0.0.8, mute-stream@~0.0.4: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + nan@^2.12.1: version "2.16.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" @@ -16419,6 +16889,14 @@ postcss-flexbugs-fixes@^4.2.1: dependencies: postcss "^7.0.26" +postcss-load-config@^3.0.1: + version "3.1.4" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.4.tgz#1ab2571faf84bb078877e1d07905eabe9ebda855" + integrity sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg== + dependencies: + lilconfig "^2.0.5" + yaml "^1.10.2" + postcss-loader@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-4.3.0.tgz#2c4de9657cd4f07af5ab42bd60a673004da1b8cc" @@ -16597,6 +17075,16 @@ pretty-error@^2.1.1: lodash "^4.17.20" renderkid "^2.0.4" +pretty-format@^24.9.0: + version "24.9.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" + integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA== + dependencies: + "@jest/types" "^24.9.0" + ansi-regex "^4.0.0" + ansi-styles "^3.2.0" + react-is "^16.8.4" + pretty-format@^26.0.0, pretty-format@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" @@ -17104,7 +17592,7 @@ react-is@17.0.2, "react-is@^16.8.0 || ^17.0.0", react-is@^17.0.0, react-is@^17.0 resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -react-is@^16.10.2, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0: +react-is@^16.10.2, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.4: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -17971,6 +18459,13 @@ rollup@^2.70.1: optionalDependencies: fsevents "~2.3.2" +rollup@^2.74.1: + version "2.77.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.77.0.tgz#749eaa5ac09b6baa52acc076bc46613eddfd53f4" + integrity sha512-vL8xjY4yOQEw79DvyXLijhnhh+R/O9zpF/LEgkCebZFtb6ELeN9H3/2T0r8+mp+fFTBHZ5qGpOpW2ela2zRt3g== + optionalDependencies: + fsevents "~2.3.2" + rollup@^2.75.6: version "2.76.0" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.76.0.tgz#c69fe03db530ac53fcb9523b3caa0d3c0b9491a1" @@ -18568,6 +19063,13 @@ source-map-url@^0.4.0: resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== +source-map@0.8.0-beta.0: + version "0.8.0-beta.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.8.0-beta.0.tgz#d4c1bb42c3f7ee925f005927ba10709e0d1d1f11" + integrity sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA== + dependencies: + whatwg-url "^7.0.0" + source-map@^0.5.0, source-map@^0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -19213,6 +19715,18 @@ stylelint@^14.5.3: v8-compile-cache "^2.3.0" write-file-atomic "^4.0.1" +sucrase@^3.20.3: + version "3.24.0" + resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.24.0.tgz#66a8f2cc845bc441706ce5f3056de283289067b6" + integrity sha512-SevqflhW356TKEyWjFHg2e5f3eH+5rzmsMJxrVMDvZIEHh/goYrpzDGA6APEj4ME9MdGm8oNgIzi1eF3c3dDQA== + dependencies: + commander "^4.0.0" + glob "7.1.6" + lines-and-columns "^1.1.6" + mz "^2.7.0" + pirates "^4.0.1" + ts-interface-checker "^0.1.9" + superstruct@^0.14.2: version "0.14.2" resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" @@ -19507,6 +20021,20 @@ themeprovider-storybook@^1.7.2: react-json-view "^1.21.3" styled-react-modal "^2.0.1" +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.1" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== + dependencies: + any-promise "^1.0.0" + throat@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/throat/-/throat-6.0.1.tgz#d514fedad95740c12c2d7fc70ea863eb51ade375" @@ -19657,6 +20185,13 @@ tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" +tr46@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA== + dependencies: + punycode "^2.1.0" + tr46@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240" @@ -19669,6 +20204,11 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= +tree-kill@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" + integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== + trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -19714,6 +20254,11 @@ ts-essentials@^7.0.1: resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38" integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ== +ts-interface-checker@^0.1.9: + version "0.1.13" + resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" + integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== + ts-jest@^27.1.3: version "27.1.3" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.3.tgz#1f723e7e74027c4da92c0ffbd73287e8af2b2957" @@ -19787,6 +20332,26 @@ tslib@^2.0.1, tslib@^2.0.3, tslib@^2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tsup@^5.10.1: + version "5.12.9" + resolved "https://registry.yarnpkg.com/tsup/-/tsup-5.12.9.tgz#8cdd9b4bc6493317cb92edf5f3476920dddcdb18" + integrity sha512-dUpuouWZYe40lLufo64qEhDpIDsWhRbr2expv5dHEMjwqeKJS2aXA/FPqs1dxO4T6mBojo7rvo3jP9NNzaKyDg== + dependencies: + bundle-require "^3.0.2" + cac "^6.7.12" + chokidar "^3.5.1" + debug "^4.3.1" + esbuild "^0.14.25" + execa "^5.0.0" + globby "^11.0.3" + joycon "^3.0.1" + postcss-load-config "^3.0.1" + resolve-from "^5.0.0" + rollup "^2.74.1" + source-map "0.8.0-beta.0" + sucrase "^3.20.3" + tree-kill "^1.2.2" + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -20665,6 +21230,11 @@ webidl-conversions@^3.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= +webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== + webidl-conversions@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" @@ -20828,6 +21398,15 @@ whatwg-url@^5.0.0: tr46 "~0.0.3" webidl-conversions "^3.0.0" +whatwg-url@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06" + integrity sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" + whatwg-url@^8.0.0, whatwg-url@^8.4.0, whatwg-url@^8.5.0: version "8.7.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.7.0.tgz#656a78e510ff8f3937bc0bcbe9f5c0ac35941b77"