@juiceswapxyz/sdk-core 3.0.0 → 3.0.2

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.
@@ -0,0 +1,84 @@
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
+ proxyAdminAddress?: string;
16
+ v4PoolManagerAddress?: string;
17
+ v4PositionManagerAddress?: string;
18
+ v4StateView?: string;
19
+ v4QuoterAddress?: string;
20
+ juiceSwapGatewayAddress?: string;
21
+ juiceSwapGovernorAddress?: string;
22
+ juiceSwapFeeCollectorAddress?: string;
23
+ l0UsdcAddress?: string;
24
+ l0UsdtAddress?: string;
25
+ l0WbtcAddress?: string;
26
+ l0UsdcOftAddress?: string;
27
+ l0UsdtOftAddress?: string;
28
+ l0WbtcOftAddress?: string;
29
+ };
30
+ export declare const UNI_ADDRESSES: AddressMap;
31
+ export declare const UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS = "0x8B799381ac40b838BBA4131ffB26197C432AFe78";
32
+ /**
33
+ * @deprecated use V2_FACTORY_ADDRESSES instead
34
+ */
35
+ export declare const V2_FACTORY_ADDRESS = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
36
+ export declare const V2_FACTORY_ADDRESSES: AddressMap;
37
+ /**
38
+ * @deprecated use V2_ROUTER_ADDRESSES instead
39
+ */
40
+ export declare const V2_ROUTER_ADDRESS = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
41
+ export declare const V2_ROUTER_ADDRESSES: AddressMap;
42
+ /**
43
+ * V2 Pair init code hash for CREATE2 pair address computation.
44
+ * Computed from: keccak256(UniswapV2Pair.creationCode)
45
+ * Source: @juiceswapxyz/v2-core (branded LP tokens: "JuiceSwap V2" / "JUICE-V2")
46
+ * Must match: v2-periphery/contracts/libraries/UniswapV2Library.sol line 29
47
+ */
48
+ export declare const V2_INIT_CODE_HASH = "0xdc3b9f52403077ec7261ad325e15f34e395cf7e2a5c3782098edb10a7599cc3e";
49
+ export declare const CHAIN_TO_ADDRESSES_MAP: Record<SupportedChainsType, ChainAddresses>;
50
+ export declare const V3_CORE_FACTORY_ADDRESSES: AddressMap;
51
+ export declare const V3_MIGRATOR_ADDRESSES: AddressMap;
52
+ export declare const MULTICALL_ADDRESSES: AddressMap;
53
+ /**
54
+ * The oldest V0 governance address
55
+ */
56
+ export declare const GOVERNANCE_ALPHA_V0_ADDRESSES: AddressMap;
57
+ /**
58
+ * The older V1 governance address
59
+ */
60
+ export declare const GOVERNANCE_ALPHA_V1_ADDRESSES: AddressMap;
61
+ /**
62
+ * The latest governor bravo that is currently admin of timelock
63
+ */
64
+ export declare const GOVERNANCE_BRAVO_ADDRESSES: AddressMap;
65
+ export declare const TIMELOCK_ADDRESSES: AddressMap;
66
+ export declare const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap;
67
+ export declare const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap;
68
+ export declare const QUOTER_ADDRESSES: AddressMap;
69
+ export declare const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap;
70
+ export declare const ENS_REGISTRAR_ADDRESSES: AddressMap;
71
+ export declare const SOCKS_CONTROLLER_ADDRESSES: AddressMap;
72
+ export declare const TICK_LENS_ADDRESSES: AddressMap;
73
+ export declare const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap;
74
+ export declare const SWAP_ROUTER_02_ADDRESSES: (chainId: number) => string;
75
+ export declare const JUICESWAP_GATEWAY_ADDRESSES: AddressMap;
76
+ export declare const JUICESWAP_GOVERNOR_ADDRESSES: AddressMap;
77
+ export declare const JUICESWAP_FEE_COLLECTOR_ADDRESSES: AddressMap;
78
+ export declare const L0_USDC_ADDRESSES: AddressMap;
79
+ export declare const L0_USDT_ADDRESSES: AddressMap;
80
+ export declare const L0_WBTC_ADDRESSES: AddressMap;
81
+ export declare const L0_USDC_OFT_ADDRESSES: AddressMap;
82
+ export declare const L0_USDT_OFT_ADDRESSES: AddressMap;
83
+ export declare const L0_WBTC_OFT_ADDRESSES: AddressMap;
84
+ export {};
@@ -0,0 +1,47 @@
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
+ SONEIUM = 1868,
32
+ CITREA_TESTNET = 5115,
33
+ CITREA_MAINNET = 4114
34
+ }
35
+ 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, ChainId.SONEIUM, ChainId.CITREA_TESTNET, ChainId.CITREA_MAINNET];
36
+ export declare type SupportedChainsType = (typeof SUPPORTED_CHAINS)[number];
37
+ export declare enum NativeCurrencyName {
38
+ ETHER = "ETH",
39
+ MATIC = "MATIC",
40
+ CELO = "CELO",
41
+ GNOSIS = "XDAI",
42
+ MOONBEAM = "GLMR",
43
+ BNB = "BNB",
44
+ AVAX = "AVAX",
45
+ ROOTSTOCK = "RBTC",
46
+ CITREA_BTC = "cBTC"
47
+ }
@@ -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,19 @@
1
+ import { Token } from './token';
2
+ /**
3
+ * Bridged USDC.e on Citrea Mainnet (via LayerZero)
4
+ */
5
+ export declare const USDC_E: {
6
+ [chainId: number]: Token;
7
+ };
8
+ /**
9
+ * Bridged USDT.e on Citrea Mainnet (via LayerZero)
10
+ */
11
+ export declare const USDT_E: {
12
+ [chainId: number]: Token;
13
+ };
14
+ /**
15
+ * Bridged WBTC.e on Citrea Mainnet (via LayerZero OFT)
16
+ */
17
+ export declare const WBTC_E: {
18
+ [chainId: number]: Token;
19
+ };
@@ -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,7 @@
1
+ export * from './fractions';
2
+ export * from './currency';
3
+ export * from './ether';
4
+ export * from './nativeCurrency';
5
+ export * from './token';
6
+ export * from './weth9';
7
+ export * from './bridgedTokens';
@@ -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
+ }