@huuduynvc/sdk-core 7.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Uniswap Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Uniswap SDK Core
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@uniswap/sdk-core/latest.svg)](https://www.npmjs.com/package/@uniswap/sdk-core/v/latest)
4
+ [![npm bundle size (scoped version)](https://img.shields.io/bundlephobia/minzip/@uniswap/sdk-core/latest.svg)](https://bundlephobia.com/result?p=@uniswap/sdk-core@latest)
5
+
6
+ This code is shared across Uniswap TypeScript SDKs.
@@ -0,0 +1,58 @@
1
+ import { SupportedChainsType } from './chains';
2
+ declare type AddressMap = {
3
+ [chainId: number]: string;
4
+ };
5
+ declare type ChainAddresses = {
6
+ v3CoreFactoryAddress: string;
7
+ multicallAddress: string;
8
+ quoterAddress: string;
9
+ v3MigratorAddress?: string;
10
+ nonfungiblePositionManagerAddress?: string;
11
+ tickLensAddress?: string;
12
+ swapRouter02Address?: string;
13
+ mixedRouteQuoterV1Address?: string;
14
+ mixedRouteQuoterV2Address?: string;
15
+ v4PoolManagerAddress?: string;
16
+ v4PositionManagerAddress?: string;
17
+ v4StateView?: string;
18
+ v4QuoterAddress?: string;
19
+ };
20
+ export declare const UNI_ADDRESSES: AddressMap;
21
+ export declare const UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS = "0x8B799381ac40b838BBA4131ffB26197C432AFe78";
22
+ /**
23
+ * @deprecated use V2_FACTORY_ADDRESSES instead
24
+ */
25
+ export declare const V2_FACTORY_ADDRESS = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
26
+ export declare const V2_FACTORY_ADDRESSES: AddressMap;
27
+ /**
28
+ * @deprecated use V2_ROUTER_ADDRESSES instead
29
+ */
30
+ export declare const V2_ROUTER_ADDRESS = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
31
+ export declare const V2_ROUTER_ADDRESSES: AddressMap;
32
+ export declare const CHAIN_TO_ADDRESSES_MAP: Record<SupportedChainsType, ChainAddresses>;
33
+ export declare const V3_CORE_FACTORY_ADDRESSES: AddressMap;
34
+ export declare const V3_MIGRATOR_ADDRESSES: AddressMap;
35
+ export declare const MULTICALL_ADDRESSES: AddressMap;
36
+ /**
37
+ * The oldest V0 governance address
38
+ */
39
+ export declare const GOVERNANCE_ALPHA_V0_ADDRESSES: AddressMap;
40
+ /**
41
+ * The older V1 governance address
42
+ */
43
+ export declare const GOVERNANCE_ALPHA_V1_ADDRESSES: AddressMap;
44
+ /**
45
+ * The latest governor bravo that is currently admin of timelock
46
+ */
47
+ export declare const GOVERNANCE_BRAVO_ADDRESSES: AddressMap;
48
+ export declare const TIMELOCK_ADDRESSES: AddressMap;
49
+ export declare const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap;
50
+ export declare const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap;
51
+ export declare const QUOTER_ADDRESSES: AddressMap;
52
+ export declare const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap;
53
+ export declare const ENS_REGISTRAR_ADDRESSES: AddressMap;
54
+ export declare const SOCKS_CONTROLLER_ADDRESSES: AddressMap;
55
+ export declare const TICK_LENS_ADDRESSES: AddressMap;
56
+ export declare const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap;
57
+ export declare const SWAP_ROUTER_02_ADDRESSES: (chainId: number) => string;
58
+ export {};
@@ -0,0 +1,43 @@
1
+ export declare enum ChainId {
2
+ MAINNET = 1,
3
+ GOERLI = 5,
4
+ SEPOLIA = 11155111,
5
+ OPTIMISM = 10,
6
+ OPTIMISM_GOERLI = 420,
7
+ OPTIMISM_SEPOLIA = 11155420,
8
+ ARBITRUM_ONE = 42161,
9
+ ARBITRUM_GOERLI = 421613,
10
+ ARBITRUM_SEPOLIA = 421614,
11
+ POLYGON = 137,
12
+ POLYGON_MUMBAI = 80001,
13
+ CELO = 42220,
14
+ CELO_ALFAJORES = 44787,
15
+ GNOSIS = 100,
16
+ MOONBEAM = 1284,
17
+ BNB = 56,
18
+ AVALANCHE = 43114,
19
+ BASE_GOERLI = 84531,
20
+ BASE_SEPOLIA = 84532,
21
+ BASE = 8453,
22
+ ZORA = 7777777,
23
+ ZORA_SEPOLIA = 999999999,
24
+ ROOTSTOCK = 30,
25
+ BLAST = 81457,
26
+ ZKSYNC = 324,
27
+ WORLDCHAIN = 480,
28
+ UNICHAIN_SEPOLIA = 1301,
29
+ UNICHAIN = 130,
30
+ MONAD_TESTNET = 10143
31
+ }
32
+ export declare const SUPPORTED_CHAINS: readonly [ChainId.MAINNET, ChainId.OPTIMISM, ChainId.OPTIMISM_GOERLI, ChainId.OPTIMISM_SEPOLIA, ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_GOERLI, ChainId.ARBITRUM_SEPOLIA, ChainId.POLYGON, ChainId.POLYGON_MUMBAI, ChainId.GOERLI, ChainId.SEPOLIA, ChainId.CELO_ALFAJORES, ChainId.CELO, ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE, ChainId.BASE_GOERLI, ChainId.BASE_SEPOLIA, ChainId.ZORA, ChainId.ZORA_SEPOLIA, ChainId.ROOTSTOCK, ChainId.BLAST, ChainId.ZKSYNC, ChainId.WORLDCHAIN, ChainId.UNICHAIN_SEPOLIA, ChainId.UNICHAIN, ChainId.MONAD_TESTNET];
33
+ export declare type SupportedChainsType = (typeof SUPPORTED_CHAINS)[number];
34
+ export declare enum NativeCurrencyName {
35
+ ETHER = "ETH",
36
+ MATIC = "MATIC",
37
+ CELO = "CELO",
38
+ GNOSIS = "XDAI",
39
+ MOONBEAM = "GLMR",
40
+ BNB = "BNB",
41
+ AVAX = "AVAX",
42
+ ROOTSTOCK = "RBTC"
43
+ }
@@ -0,0 +1,12 @@
1
+ import JSBI from 'jsbi';
2
+ export declare type BigintIsh = JSBI | string | number;
3
+ export declare enum TradeType {
4
+ EXACT_INPUT = 0,
5
+ EXACT_OUTPUT = 1
6
+ }
7
+ export declare enum Rounding {
8
+ ROUND_DOWN = 0,
9
+ ROUND_HALF_UP = 1,
10
+ ROUND_UP = 2
11
+ }
12
+ export declare const MaxUint256: JSBI;
@@ -0,0 +1,49 @@
1
+ import { Currency } from './currency';
2
+ import { Token } from './token';
3
+ /**
4
+ * A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
5
+ */
6
+ export declare abstract class BaseCurrency {
7
+ /**
8
+ * Returns whether the currency is native to the chain and must be wrapped (e.g. Ether)
9
+ */
10
+ abstract readonly isNative: boolean;
11
+ /**
12
+ * Returns whether the currency is a token that is usable in Uniswap without wrapping
13
+ */
14
+ abstract readonly isToken: boolean;
15
+ /**
16
+ * The chain ID on which this currency resides
17
+ */
18
+ readonly chainId: number;
19
+ /**
20
+ * The decimals used in representing currency amounts
21
+ */
22
+ readonly decimals: number;
23
+ /**
24
+ * The symbol of the currency, i.e. a short textual non-unique identifier
25
+ */
26
+ readonly symbol?: string;
27
+ /**
28
+ * The name of the currency, i.e. a descriptive textual non-unique identifier
29
+ */
30
+ readonly name?: string;
31
+ /**
32
+ * Constructs an instance of the base class `BaseCurrency`.
33
+ * @param chainId the chain ID on which this currency resides
34
+ * @param decimals decimals of the currency
35
+ * @param symbol symbol of the currency
36
+ * @param name of the currency
37
+ */
38
+ protected constructor(chainId: number, decimals: number, symbol?: string, name?: string);
39
+ /**
40
+ * Returns whether this currency is functionally equivalent to the other currency
41
+ * @param other the other currency
42
+ */
43
+ abstract equals(other: Currency): boolean;
44
+ /**
45
+ * Return the wrapped version of this currency that can be used with the Uniswap contracts. Currencies must
46
+ * implement this to be used in Uniswap
47
+ */
48
+ abstract get wrapped(): Token;
49
+ }
@@ -0,0 +1,3 @@
1
+ import { NativeCurrency } from './nativeCurrency';
2
+ import { Token } from './token';
3
+ export declare type Currency = NativeCurrency | Token;
@@ -0,0 +1,13 @@
1
+ import { Currency } from './currency';
2
+ import { NativeCurrency } from './nativeCurrency';
3
+ import { Token } from './token';
4
+ /**
5
+ * Ether is the main usage of a 'native' currency, i.e. for Ethereum mainnet and all testnets
6
+ */
7
+ export declare class Ether extends NativeCurrency {
8
+ protected constructor(chainId: number);
9
+ get wrapped(): Token;
10
+ private static _etherCache;
11
+ static onChain(chainId: number): Ether;
12
+ equals(other: Currency): boolean;
13
+ }
@@ -0,0 +1,31 @@
1
+ import JSBI from 'jsbi';
2
+ import { Currency } from '../currency';
3
+ import { Token } from '../token';
4
+ import { Fraction } from './fraction';
5
+ import { BigintIsh, Rounding } from '../../constants';
6
+ export declare class CurrencyAmount<T extends Currency> extends Fraction {
7
+ readonly currency: T;
8
+ readonly decimalScale: JSBI;
9
+ /**
10
+ * Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
11
+ * @param currency the currency in the amount
12
+ * @param rawAmount the raw token or ether amount
13
+ */
14
+ static fromRawAmount<T extends Currency>(currency: T, rawAmount: BigintIsh): CurrencyAmount<T>;
15
+ /**
16
+ * Construct a currency amount with a denominator that is not equal to 1
17
+ * @param currency the currency
18
+ * @param numerator the numerator of the fractional token amount
19
+ * @param denominator the denominator of the fractional token amount
20
+ */
21
+ static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
22
+ protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
23
+ add(other: CurrencyAmount<T>): CurrencyAmount<T>;
24
+ subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
25
+ multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
26
+ divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
27
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
28
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
29
+ toExact(format?: object): string;
30
+ get wrapped(): CurrencyAmount<Token>;
31
+ }
@@ -0,0 +1,24 @@
1
+ import JSBI from 'jsbi';
2
+ import { BigintIsh, Rounding } from '../../constants';
3
+ export declare class Fraction {
4
+ readonly numerator: JSBI;
5
+ readonly denominator: JSBI;
6
+ constructor(numerator: BigintIsh, denominator?: BigintIsh);
7
+ private static tryParseFraction;
8
+ get quotient(): JSBI;
9
+ get remainder(): Fraction;
10
+ invert(): Fraction;
11
+ add(other: Fraction | BigintIsh): Fraction;
12
+ subtract(other: Fraction | BigintIsh): Fraction;
13
+ lessThan(other: Fraction | BigintIsh): boolean;
14
+ equalTo(other: Fraction | BigintIsh): boolean;
15
+ greaterThan(other: Fraction | BigintIsh): boolean;
16
+ multiply(other: Fraction | BigintIsh): Fraction;
17
+ divide(other: Fraction | BigintIsh): Fraction;
18
+ toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
19
+ toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
20
+ /**
21
+ * Helper method for converting any super class back to a fraction
22
+ */
23
+ get asFraction(): Fraction;
24
+ }
@@ -0,0 +1,4 @@
1
+ export { CurrencyAmount } from './currencyAmount';
2
+ export { Fraction } from './fraction';
3
+ export { Percent } from './percent';
4
+ export { Price } from './price';
@@ -0,0 +1,14 @@
1
+ import { BigintIsh, Rounding } from '../../constants';
2
+ import { Fraction } from './fraction';
3
+ export declare class Percent extends Fraction {
4
+ /**
5
+ * This boolean prevents a fraction from being interpreted as a Percent
6
+ */
7
+ readonly isPercent: true;
8
+ add(other: Fraction | BigintIsh): Percent;
9
+ subtract(other: Fraction | BigintIsh): Percent;
10
+ multiply(other: Fraction | BigintIsh): Percent;
11
+ divide(other: Fraction | BigintIsh): Percent;
12
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
13
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { BigintIsh, Rounding } from '../../constants';
2
+ import { Currency } from '../currency';
3
+ import { Fraction } from './fraction';
4
+ import { CurrencyAmount } from './currencyAmount';
5
+ export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
6
+ readonly baseCurrency: TBase;
7
+ readonly quoteCurrency: TQuote;
8
+ readonly scalar: Fraction;
9
+ /**
10
+ * Construct a price, either with the base and quote currency amount, or the
11
+ * @param args
12
+ */
13
+ constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
14
+ baseAmount: CurrencyAmount<TBase>;
15
+ quoteAmount: CurrencyAmount<TQuote>;
16
+ }]);
17
+ /**
18
+ * Flip the price, switching the base and quote currency
19
+ */
20
+ invert(): Price<TQuote, TBase>;
21
+ /**
22
+ * Multiply the price by another price, returning a new price. The other price must have the same base currency as this price's quote currency
23
+ * @param other the other price
24
+ */
25
+ multiply<TOtherQuote extends Currency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
26
+ /**
27
+ * Return the amount of quote currency corresponding to a given amount of the base currency
28
+ * @param currencyAmount the amount of base currency to quote against the price
29
+ */
30
+ quote(currencyAmount: CurrencyAmount<TBase>): CurrencyAmount<TQuote>;
31
+ /**
32
+ * Get the value scaled by decimals for formatting
33
+ * @private
34
+ */
35
+ private get adjustedForDecimals();
36
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
37
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
38
+ }
@@ -0,0 +1,6 @@
1
+ export * from './fractions';
2
+ export * from './currency';
3
+ export * from './ether';
4
+ export * from './nativeCurrency';
5
+ export * from './token';
6
+ export * from './weth9';
@@ -0,0 +1,8 @@
1
+ import { BaseCurrency } from './baseCurrency';
2
+ /**
3
+ * Represents the native currency of the chain on which it resides, e.g.
4
+ */
5
+ export declare abstract class NativeCurrency extends BaseCurrency {
6
+ readonly isNative: true;
7
+ readonly isToken: false;
8
+ }
@@ -0,0 +1,48 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { BaseCurrency } from './baseCurrency';
3
+ import { Currency } from './currency';
4
+ /**
5
+ * Represents an ERC20 token with a unique address and some metadata.
6
+ */
7
+ export declare class Token extends BaseCurrency {
8
+ readonly isNative: false;
9
+ readonly isToken: true;
10
+ /**
11
+ * The contract address on the chain on which this token lives
12
+ */
13
+ readonly address: string;
14
+ /**
15
+ * Relevant for fee-on-transfer (FOT) token taxes,
16
+ * Not every ERC20 token is FOT token, so this field is optional
17
+ */
18
+ readonly buyFeeBps?: BigNumber;
19
+ readonly sellFeeBps?: BigNumber;
20
+ /**
21
+ *
22
+ * @param chainId {@link BaseCurrency#chainId}
23
+ * @param address The contract address on the chain on which this token lives
24
+ * @param decimals {@link BaseCurrency#decimals}
25
+ * @param symbol {@link BaseCurrency#symbol}
26
+ * @param name {@link BaseCurrency#name}
27
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
28
+ * @param buyFeeBps Buy fee tax for FOT tokens, in basis points
29
+ * @param sellFeeBps Sell fee tax for FOT tokens, in basis points
30
+ */
31
+ constructor(chainId: number, address: string, decimals: number, symbol?: string, name?: string, bypassChecksum?: boolean, buyFeeBps?: BigNumber, sellFeeBps?: BigNumber);
32
+ /**
33
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
34
+ * @param other other token to compare
35
+ */
36
+ equals(other: Currency): boolean;
37
+ /**
38
+ * Returns true if the address of this token sorts before the address of the other token
39
+ * @param other other token to compare
40
+ * @throws if the tokens have the same address
41
+ * @throws if the tokens are on different chains
42
+ */
43
+ sortsBefore(other: Token): boolean;
44
+ /**
45
+ * Return this token, which does not need to be wrapped
46
+ */
47
+ get wrapped(): Token;
48
+ }
@@ -0,0 +1,7 @@
1
+ import { Token } from './token';
2
+ /**
3
+ * Known WETH9 implementation addresses, used in our implementation of Ether#wrapped
4
+ */
5
+ export declare const WETH9: {
6
+ [chainId: number]: Token;
7
+ };
@@ -0,0 +1,5 @@
1
+ export * from './addresses';
2
+ export * from './chains';
3
+ export * from './constants';
4
+ export * from './entities';
5
+ export * from './utils';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./sdk-core.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./sdk-core.cjs.development.js')
8
+ }