@qidao/sdk 5.0.6 → 5.0.9
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/dist/constants/addresses.d.ts +31 -0
- package/dist/constants/index.d.ts +20 -0
- package/dist/constants/kashi.d.ts +29 -0
- package/dist/constants/natives.d.ts +30 -0
- package/dist/constants/numbers.d.ts +11 -0
- package/dist/constants/tokens.d.ts +5 -0
- package/dist/entities/AbstractCurrency.d.ts +53 -0
- package/dist/entities/ConstantProductPool.d.ts +43 -0
- package/dist/entities/Currency.d.ts +3 -0
- package/dist/entities/CurrencyAmount.d.ts +38 -0
- package/dist/entities/{fractions/fraction.d.ts → Fraction.d.ts} +7 -1
- package/dist/entities/MultiRouter.d.ts +59 -0
- package/dist/entities/Native/Avalanche.d.ts +10 -0
- package/dist/entities/Native/Binance.d.ts +10 -0
- package/dist/entities/Native/Celo.d.ts +10 -0
- package/dist/entities/Native/Ether.d.ts +13 -0
- package/dist/entities/Native/Fantom.d.ts +10 -0
- package/dist/entities/Native/Fuse.d.ts +10 -0
- package/dist/entities/Native/Harmony.d.ts +10 -0
- package/dist/entities/Native/Heco.d.ts +10 -0
- package/dist/entities/Native/Matic.d.ts +10 -0
- package/dist/entities/Native/Movr.d.ts +10 -0
- package/dist/entities/Native/Okex.d.ts +10 -0
- package/dist/entities/Native/Palm.d.ts +10 -0
- package/dist/entities/Native/Telos.d.ts +10 -0
- package/dist/entities/Native/index.d.ts +14 -0
- package/dist/entities/Native/xDai.d.ts +10 -0
- package/dist/entities/NativeCurrency.d.ts +8 -0
- package/dist/entities/Pair.d.ts +41 -0
- package/dist/entities/Percent.d.ts +15 -0
- package/dist/entities/Price.d.ts +39 -0
- package/dist/entities/Route.d.ts +14 -0
- package/dist/entities/{token.d.ts → Token.d.ts} +11 -39
- package/dist/entities/{trade.d.ts → Trade.d.ts} +35 -34
- package/dist/entities/eip712.d.ts +78 -0
- package/dist/entities/index.d.ts +14 -6
- package/dist/enums/ChainId.d.ts +32 -0
- package/dist/enums/Fee.d.ts +3 -0
- package/dist/enums/KashiAction.d.ts +18 -0
- package/dist/enums/OrderStatus.d.ts +6 -0
- package/dist/enums/Rounding.d.ts +5 -0
- package/dist/enums/TradeType.d.ts +4 -0
- package/dist/enums/index.d.ts +6 -0
- package/dist/functions/bentobox.d.ts +3 -0
- package/dist/functions/computeConstantProductPoolAddress.d.ts +9 -0
- package/dist/functions/computePairAddress.d.ts +6 -0
- package/dist/functions/computePoolInitCodeHash.d.ts +5 -0
- package/dist/functions/computePriceImpact.d.ts +11 -0
- package/dist/functions/index.d.ts +8 -0
- package/dist/functions/kashi.d.ts +9 -0
- package/dist/functions/rebase.d.ts +4 -0
- package/dist/functions/sortedInsert.d.ts +1 -0
- package/dist/functions/sqrt.d.ts +7 -0
- package/dist/functions/validateAndParseAddress.d.ts +1 -0
- package/dist/functions/validateSolidityTypeInstance.d.ts +3 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +2 -2
- package/dist/interfaces/AccrueInfo.d.ts +6 -0
- package/dist/interfaces/Rebase.d.ts +5 -0
- package/dist/interfaces/index.d.ts +2 -0
- package/dist/limitorder.d.ts +115 -0
- package/dist/qidao-sdk.cjs.development.js +5301 -0
- package/dist/qidao-sdk.cjs.development.js.map +1 -0
- package/dist/qidao-sdk.cjs.production.min.js +2 -0
- package/dist/qidao-sdk.cjs.production.min.js.map +1 -0
- package/dist/qidao-sdk.esm.js +5162 -0
- package/dist/qidao-sdk.esm.js.map +1 -0
- package/dist/router.d.ts +7 -2
- package/dist/types/AddressMap.d.ts +3 -0
- package/dist/types/BigIntIsh.d.ts +2 -0
- package/dist/types/ChainTokenMap.d.ts +5 -0
- package/dist/types/LimitOrderTypes.d.ts +21 -0
- package/dist/types/MultiRouterTypes.d.ts +97 -0
- package/dist/types/TokenMap.d.ts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/utils/MultiRouterMath.d.ts +15 -0
- package/package.json +57 -31
- package/dist/constants.d.ts +0 -86
- package/dist/entities/currency.d.ts +0 -81
- package/dist/entities/fractions/currencyAmount.d.ts +0 -19
- package/dist/entities/fractions/index.d.ts +0 -5
- package/dist/entities/fractions/percent.d.ts +0 -6
- package/dist/entities/fractions/price.d.ts +0 -19
- package/dist/entities/fractions/tokenAmount.d.ts +0 -9
- package/dist/entities/pair.d.ts +0 -41
- package/dist/entities/route.d.ts +0 -14
- package/dist/fetcher.d.ts +0 -28
- package/dist/sdk.cjs.development.js +0 -1708
- package/dist/sdk.cjs.development.js.map +0 -1
- package/dist/sdk.cjs.production.min.js +0 -2
- package/dist/sdk.cjs.production.min.js.map +0 -1
- package/dist/sdk.esm.js +0 -1680
- package/dist/sdk.esm.js.map +0 -1
- package/dist/test/constants.test.d.ts +0 -1
- package/dist/test/data.test.d.ts +0 -1
- package/dist/test/entities.test.d.ts +0 -1
- package/dist/test/fraction.test.d.ts +0 -1
- package/dist/test/miscellaneous.test.d.ts +0 -1
- package/dist/test/pair.test.d.ts +0 -1
- package/dist/test/route.test.d.ts +0 -1
- package/dist/test/router.test.d.ts +0 -1
- package/dist/test/token.test.d.ts +0 -1
- package/dist/test/trade.test.d.ts +0 -1
- package/dist/utils.d.ts +0 -7
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AddressMap } from '../types';
|
|
2
|
+
export declare const USDC_ADDRESS: AddressMap;
|
|
3
|
+
export declare const USD_ADDRESS: AddressMap;
|
|
4
|
+
export declare const FACTORY_ADDRESS: AddressMap;
|
|
5
|
+
export declare const ROUTER_ADDRESS: AddressMap;
|
|
6
|
+
export declare const SUSHI_ADDRESS: AddressMap;
|
|
7
|
+
export declare const MASTERCHEF_ADDRESS: AddressMap;
|
|
8
|
+
export declare const BAR_ADDRESS: AddressMap;
|
|
9
|
+
export declare const MAKER_ADDRESS: AddressMap;
|
|
10
|
+
export declare const TIMELOCK_ADDRESS: AddressMap;
|
|
11
|
+
export declare const BENTOBOX_ADDRESS: AddressMap;
|
|
12
|
+
export declare const KASHI_ADDRESS: AddressMap;
|
|
13
|
+
export declare const SUSHISWAP_SWAPPER_ADDRESS: AddressMap;
|
|
14
|
+
export declare const SUSHISWAP_MULTISWAPPER_ADDRESS: AddressMap;
|
|
15
|
+
export declare const SUSHISWAP_MULTI_EXACT_SWAPPER_ADDRESS: AddressMap;
|
|
16
|
+
export declare const PEGGED_ORACLE_ADDRESS = "0x6cbfbB38498Df0E1e7A4506593cDB02db9001564";
|
|
17
|
+
export declare const SUSHISWAP_TWAP_0_ORACLE_ADDRESS = "0x66F03B0d30838A3fee971928627ea6F59B236065";
|
|
18
|
+
export declare const SUSHISWAP_TWAP_1_ORACLE_ADDRESS = "0x0D51b575591F8f74a2763Ade75D3CDCf6789266f";
|
|
19
|
+
export declare const CHAINLINK_ORACLE_ADDRESS: AddressMap;
|
|
20
|
+
export declare const BORING_HELPER_ADDRESS: AddressMap;
|
|
21
|
+
export declare const STOP_LIMIT_ORDER_ADDRESS: AddressMap;
|
|
22
|
+
export declare const ARCHER_ROUTER_ADDRESS: AddressMap;
|
|
23
|
+
export declare const MINICHEF_ADDRESS: AddressMap;
|
|
24
|
+
export declare const OLD_FARMS: AddressMap;
|
|
25
|
+
export declare const WETH9_ADDRESS: AddressMap;
|
|
26
|
+
export declare const WNATIVE_ADDRESS: AddressMap;
|
|
27
|
+
export declare const MASTERCHEF_V2_ADDRESS: AddressMap;
|
|
28
|
+
export declare const ENS_REGISTRAR_ADDRESS: AddressMap;
|
|
29
|
+
export declare const ZAPPER_ADDRESS: AddressMap;
|
|
30
|
+
export declare const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap;
|
|
31
|
+
export declare const MULTICALL2_ADDRESS: AddressMap;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import JSBI from 'jsbi';
|
|
2
|
+
export * from './addresses';
|
|
3
|
+
export * from './kashi';
|
|
4
|
+
export * from './natives';
|
|
5
|
+
export * from './numbers';
|
|
6
|
+
export * from './tokens';
|
|
7
|
+
export declare const INIT_CODE_HASH: {
|
|
8
|
+
[chainId: number]: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const MINIMUM_LIQUIDITY: JSBI;
|
|
11
|
+
export declare enum SolidityType {
|
|
12
|
+
uint8 = "uint8",
|
|
13
|
+
uint256 = "uint256"
|
|
14
|
+
}
|
|
15
|
+
export declare const SOLIDITY_TYPE_MAXIMA: {
|
|
16
|
+
uint8: JSBI;
|
|
17
|
+
uint256: JSBI;
|
|
18
|
+
};
|
|
19
|
+
export declare const LAMBDA_URL = "https://9epjsvomc4.execute-api.us-east-1.amazonaws.com/dev";
|
|
20
|
+
export declare const SOCKET_URL = "wss://hfimt374ge.execute-api.us-east-1.amazonaws.com/dev";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
export declare const ACTION_ADD_ASSET = 1;
|
|
3
|
+
export declare const ACTION_REPAY = 2;
|
|
4
|
+
export declare const ACTION_REMOVE_ASSET = 3;
|
|
5
|
+
export declare const ACTION_REMOVE_COLLATERAL = 4;
|
|
6
|
+
export declare const ACTION_BORROW = 5;
|
|
7
|
+
export declare const ACTION_GET_REPAY_SHARE = 6;
|
|
8
|
+
export declare const ACTION_GET_REPAY_PART = 7;
|
|
9
|
+
export declare const ACTION_ACCRUE = 8;
|
|
10
|
+
export declare const ACTION_ADD_COLLATERAL = 10;
|
|
11
|
+
export declare const ACTION_UPDATE_EXCHANGE_RATE = 11;
|
|
12
|
+
export declare const ACTION_BENTO_DEPOSIT = 20;
|
|
13
|
+
export declare const ACTION_BENTO_WITHDRAW = 21;
|
|
14
|
+
export declare const ACTION_BENTO_TRANSFER = 22;
|
|
15
|
+
export declare const ACTION_BENTO_TRANSFER_MULTIPLE = 23;
|
|
16
|
+
export declare const ACTION_BENTO_SETAPPROVAL = 24;
|
|
17
|
+
export declare const ACTION_CALL = 30;
|
|
18
|
+
export declare const MINIMUM_TARGET_UTILIZATION: BigNumber;
|
|
19
|
+
export declare const MAXIMUM_TARGET_UTILIZATION: BigNumber;
|
|
20
|
+
export declare const UTILIZATION_PRECISION: BigNumber;
|
|
21
|
+
export declare const FULL_UTILIZATION: BigNumber;
|
|
22
|
+
export declare const FULL_UTILIZATION_MINUS_MAX: BigNumber;
|
|
23
|
+
export declare const STARTING_INTEREST_PER_YEAR: BigNumber;
|
|
24
|
+
export declare const MINIMUM_INTEREST_PER_YEAR: BigNumber;
|
|
25
|
+
export declare const MAXIMUM_INTEREST_PER_YEAR: BigNumber;
|
|
26
|
+
export declare const INTEREST_ELASTICITY: BigNumber;
|
|
27
|
+
export declare const FACTOR_PRECISION: BigNumber;
|
|
28
|
+
export declare const PROTOCOL_FEE: BigNumber;
|
|
29
|
+
export declare const PROTOCOL_FEE_DIVISOR: BigNumber;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Avalanche, Binance, Celo, Ether, Fantom, Fuse, Harmony, Heco, Matic, Movr, Okex, Palm, xDai, Telos } from '../entities/Native';
|
|
2
|
+
import { ChainId } from '../enums';
|
|
3
|
+
export declare const NATIVE: {
|
|
4
|
+
1: Ether;
|
|
5
|
+
3: Ether;
|
|
6
|
+
4: Ether;
|
|
7
|
+
5: Ether;
|
|
8
|
+
42: Ether;
|
|
9
|
+
250: Fantom;
|
|
10
|
+
4002: Fantom;
|
|
11
|
+
137: Matic;
|
|
12
|
+
80001: Matic;
|
|
13
|
+
100: xDai;
|
|
14
|
+
56: Binance;
|
|
15
|
+
97: Binance;
|
|
16
|
+
42161: Ether;
|
|
17
|
+
43114: Avalanche;
|
|
18
|
+
43113: Avalanche;
|
|
19
|
+
128: Heco;
|
|
20
|
+
256: Heco;
|
|
21
|
+
1666600000: Harmony;
|
|
22
|
+
1666700000: Harmony;
|
|
23
|
+
66: Okex;
|
|
24
|
+
65: Okex;
|
|
25
|
+
42220: Celo;
|
|
26
|
+
11297108109: Palm;
|
|
27
|
+
1285: Movr;
|
|
28
|
+
122: Fuse;
|
|
29
|
+
40: Telos;
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import JSBI from 'jsbi';
|
|
2
|
+
export declare const MaxUint256: JSBI;
|
|
3
|
+
export declare const ZERO: JSBI;
|
|
4
|
+
export declare const ONE: JSBI;
|
|
5
|
+
export declare const TWO: JSBI;
|
|
6
|
+
export declare const THREE: JSBI;
|
|
7
|
+
export declare const FIVE: JSBI;
|
|
8
|
+
export declare const TEN: JSBI;
|
|
9
|
+
export declare const _100: JSBI;
|
|
10
|
+
export declare const _997: JSBI;
|
|
11
|
+
export declare const _1000: JSBI;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 AbstractCurrency {
|
|
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
|
+
/**
|
|
50
|
+
* Returns token address. Useful in cases where a dependency is needed to detect changes (e.g. useEffect).
|
|
51
|
+
*/
|
|
52
|
+
serialize(): string;
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CurrencyAmount } from './CurrencyAmount';
|
|
2
|
+
import { Fee } from '../enums';
|
|
3
|
+
import { Price } from './Price';
|
|
4
|
+
import { Token } from './Token';
|
|
5
|
+
export declare class ConstantProductPool {
|
|
6
|
+
readonly liquidityToken: Token;
|
|
7
|
+
readonly fee: Fee;
|
|
8
|
+
readonly twap: boolean;
|
|
9
|
+
private readonly tokenAmounts;
|
|
10
|
+
static getAddress(tokenA: Token, tokenB: Token, fee?: Fee, twap?: boolean): string;
|
|
11
|
+
constructor(currencyAmountA: CurrencyAmount<Token>, currencyAmountB: CurrencyAmount<Token>, fee?: Fee, twap?: boolean);
|
|
12
|
+
/**
|
|
13
|
+
* Returns true if the token is either token0 or token1
|
|
14
|
+
* @param token to check
|
|
15
|
+
*/
|
|
16
|
+
involvesToken(token: Token): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
|
|
19
|
+
*/
|
|
20
|
+
get token0Price(): Price<Token, Token>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
|
|
23
|
+
*/
|
|
24
|
+
get token1Price(): Price<Token, Token>;
|
|
25
|
+
/**
|
|
26
|
+
* Return the price of the given token in terms of the other token in the pair.
|
|
27
|
+
* @param token token to return price of
|
|
28
|
+
*/
|
|
29
|
+
priceOf(token: Token): Price<Token, Token>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the chain ID of the tokens in the pair.
|
|
32
|
+
*/
|
|
33
|
+
get chainId(): number;
|
|
34
|
+
get token0(): Token;
|
|
35
|
+
get token1(): Token;
|
|
36
|
+
get reserve0(): CurrencyAmount<Token>;
|
|
37
|
+
get reserve1(): CurrencyAmount<Token>;
|
|
38
|
+
reserveOf(token: Token): CurrencyAmount<Token>;
|
|
39
|
+
getOutputAmount(inputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, ConstantProductPool];
|
|
40
|
+
getInputAmount(outputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, ConstantProductPool];
|
|
41
|
+
getLiquidityMinted(totalSupply: CurrencyAmount<Token>, tokenAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>): CurrencyAmount<Token>;
|
|
42
|
+
getLiquidityValue(token: Token, totalSupply: CurrencyAmount<Token>, liquidity: CurrencyAmount<Token>): CurrencyAmount<Token>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BigintIsh } from '../types';
|
|
2
|
+
import { Currency } from './Currency';
|
|
3
|
+
import { Fraction } from './Fraction';
|
|
4
|
+
import JSBI from 'jsbi';
|
|
5
|
+
import { Rounding } from '../enums';
|
|
6
|
+
import { Token } from './Token';
|
|
7
|
+
export declare class CurrencyAmount<T extends Currency> extends Fraction {
|
|
8
|
+
readonly currency: T;
|
|
9
|
+
readonly decimalScale: JSBI;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
|
|
12
|
+
* @param currency the currency in the amount
|
|
13
|
+
* @param rawAmount the raw token or ether amount
|
|
14
|
+
*/
|
|
15
|
+
static fromRawAmount<T extends Currency>(currency: T, rawAmount: BigintIsh): CurrencyAmount<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Construct a currency amount with a denominator that is not equal to 1
|
|
18
|
+
* @param currency the currency
|
|
19
|
+
* @param numerator the numerator of the fractional token amount
|
|
20
|
+
* @param denominator the denominator of the fractional token amount
|
|
21
|
+
*/
|
|
22
|
+
static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
|
|
23
|
+
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
|
|
24
|
+
add(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
25
|
+
subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
26
|
+
multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
27
|
+
divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
28
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
29
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
30
|
+
toExact(format?: object): string;
|
|
31
|
+
get wrapped(): CurrencyAmount<Token>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a string representation of the address and currency amount.
|
|
34
|
+
* Useful in cases where a dependency is needed to detect changes (e.g. useEffect).
|
|
35
|
+
* @return string [0x6B3595068778DD592e39A122f4f5a5cF09C90fE2 - 1323.94]
|
|
36
|
+
*/
|
|
37
|
+
serialize(): string;
|
|
38
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { BigintIsh } from '../types';
|
|
1
2
|
import JSBI from 'jsbi';
|
|
2
|
-
import {
|
|
3
|
+
import { Rounding } from '../enums';
|
|
3
4
|
export declare class Fraction {
|
|
4
5
|
readonly numerator: JSBI;
|
|
5
6
|
readonly denominator: JSBI;
|
|
6
7
|
constructor(numerator: BigintIsh, denominator?: BigintIsh);
|
|
8
|
+
private static tryParseFraction;
|
|
7
9
|
get quotient(): JSBI;
|
|
8
10
|
get remainder(): Fraction;
|
|
9
11
|
invert(): Fraction;
|
|
@@ -16,4 +18,8 @@ export declare class Fraction {
|
|
|
16
18
|
divide(other: Fraction | BigintIsh): Fraction;
|
|
17
19
|
toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
|
|
18
20
|
toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
|
|
21
|
+
/**
|
|
22
|
+
* Helper method for converting any super class back to a fraction
|
|
23
|
+
*/
|
|
24
|
+
get asFraction(): Fraction;
|
|
19
25
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import { Pool, RToken, RouteLeg, MultiRoute } from '../types/MultiRouterTypes';
|
|
3
|
+
export declare class Edge {
|
|
4
|
+
readonly GasConsumption = 40000;
|
|
5
|
+
readonly MINIMUM_LIQUIDITY = 1000;
|
|
6
|
+
pool: Pool;
|
|
7
|
+
vert0: Vertice;
|
|
8
|
+
vert1: Vertice;
|
|
9
|
+
canBeUsed: boolean;
|
|
10
|
+
direction: boolean;
|
|
11
|
+
amountInPrevious: number;
|
|
12
|
+
amountOutPrevious: number;
|
|
13
|
+
bestEdgeIncome: number;
|
|
14
|
+
constructor(p: Pool, v0: Vertice, v1: Vertice);
|
|
15
|
+
reserve(v: Vertice): BigNumber;
|
|
16
|
+
calcOutput(v: Vertice, amountIn: number): number[];
|
|
17
|
+
checkMinimalLiquidityExceededAfterSwap(from: Vertice, amountOut: number): boolean;
|
|
18
|
+
testApply(from: Vertice, amountIn: number, amountOut: number): boolean;
|
|
19
|
+
applySwap(from: Vertice): void;
|
|
20
|
+
}
|
|
21
|
+
export declare class Vertice {
|
|
22
|
+
token: RToken;
|
|
23
|
+
edges: Edge[];
|
|
24
|
+
price: number;
|
|
25
|
+
gasPrice: number;
|
|
26
|
+
bestIncome: number;
|
|
27
|
+
gasSpent: number;
|
|
28
|
+
bestTotal: number;
|
|
29
|
+
bestSource?: Edge;
|
|
30
|
+
checkLine: number;
|
|
31
|
+
constructor(t: RToken);
|
|
32
|
+
getNeibour(e?: Edge): Vertice | undefined;
|
|
33
|
+
}
|
|
34
|
+
export declare class Graph {
|
|
35
|
+
vertices: Vertice[];
|
|
36
|
+
edges: Edge[];
|
|
37
|
+
tokens: Map<RToken, Vertice>;
|
|
38
|
+
constructor(pools: Pool[], baseToken: RToken, gasPrice: number);
|
|
39
|
+
setPrices(from: Vertice, price: number, gasPrice: number): void;
|
|
40
|
+
getOrCreateVertice(token: RToken): Vertice;
|
|
41
|
+
findBestPath(from: RToken, to: RToken, amountIn: number): {
|
|
42
|
+
path: Edge[];
|
|
43
|
+
output: number;
|
|
44
|
+
gasSpent: number;
|
|
45
|
+
totalOutput: number;
|
|
46
|
+
} | undefined;
|
|
47
|
+
addPath(from: Vertice | undefined, to: Vertice | undefined, path: Edge[]): void;
|
|
48
|
+
findBestRoute(from: RToken, to: RToken, amountIn: number, mode: number | number[]): MultiRoute;
|
|
49
|
+
getRouteLegs(from: Vertice, to: Vertice): [RouteLeg[], number, boolean];
|
|
50
|
+
edgeFrom(e: Edge): [Vertice, number] | undefined;
|
|
51
|
+
getOutputEdges(v: Vertice): Edge[];
|
|
52
|
+
getInputEdges(v: Vertice): Edge[];
|
|
53
|
+
calcLegsAmountOut(legs: RouteLeg[], amountIn: number, to: RToken): number;
|
|
54
|
+
cleanTopology(from: Vertice, to: Vertice): [Vertice[], boolean];
|
|
55
|
+
removeDeadEnds(verts: Vertice[]): void;
|
|
56
|
+
removeWeakestEdge(verts: Vertice[]): void;
|
|
57
|
+
topologySort(from: Vertice, to: Vertice): [number, Vertice[]];
|
|
58
|
+
}
|
|
59
|
+
export declare function findMultiRouting(from: RToken, to: RToken, amountIn: number, pools: Pool[], baseToken: RToken, gasPrice: number, steps?: number | number[]): MultiRoute;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Avalanche extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Avalanche;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Binance extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Binance;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Celo extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Celo;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -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,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Fantom extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Fantom;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Fuse extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Fuse;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Harmony extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Harmony;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Heco extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Heco;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Matic extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Matic;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Movr extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Movr;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Okex extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Okex;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Palm extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Palm;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class Telos extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): Telos;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Avalanche } from './Avalanche';
|
|
2
|
+
export { Binance } from './Binance';
|
|
3
|
+
export { Celo } from './Celo';
|
|
4
|
+
export { Ether } from './Ether';
|
|
5
|
+
export { Fantom } from './Fantom';
|
|
6
|
+
export { Harmony } from './Harmony';
|
|
7
|
+
export { Heco } from './Heco';
|
|
8
|
+
export { Matic } from './Matic';
|
|
9
|
+
export { Movr } from './Movr';
|
|
10
|
+
export { Okex } from './Okex';
|
|
11
|
+
export { xDai } from './xDai';
|
|
12
|
+
export { Palm } from './Palm';
|
|
13
|
+
export { Fuse } from './Fuse';
|
|
14
|
+
export { Telos } from './Telos';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '../Currency';
|
|
2
|
+
import { NativeCurrency } from '../NativeCurrency';
|
|
3
|
+
import { Token } from '../Token';
|
|
4
|
+
export declare class xDai extends NativeCurrency {
|
|
5
|
+
protected constructor(chainId: number);
|
|
6
|
+
get wrapped(): Token;
|
|
7
|
+
private static _cache;
|
|
8
|
+
static onChain(chainId: number): xDai;
|
|
9
|
+
equals(other: Currency): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AbstractCurrency } from './AbstractCurrency';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the native currency of the chain on which it resides, e.g.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class NativeCurrency extends AbstractCurrency {
|
|
6
|
+
readonly isNative: true;
|
|
7
|
+
readonly isToken: false;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BigintIsh } from '../types';
|
|
2
|
+
import { CurrencyAmount } from './CurrencyAmount';
|
|
3
|
+
import { Price } from './Price';
|
|
4
|
+
import { Token } from './Token';
|
|
5
|
+
export declare class Pair {
|
|
6
|
+
readonly liquidityToken: Token;
|
|
7
|
+
private readonly tokenAmounts;
|
|
8
|
+
static getAddress(tokenA: Token, tokenB: Token): string;
|
|
9
|
+
constructor(currencyAmountA: CurrencyAmount<Token>, currencyAmountB: CurrencyAmount<Token>);
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if the token is either token0 or token1
|
|
12
|
+
* @param token to check
|
|
13
|
+
*/
|
|
14
|
+
involvesToken(token: Token): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
|
|
17
|
+
*/
|
|
18
|
+
get token0Price(): Price<Token, Token>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
|
|
21
|
+
*/
|
|
22
|
+
get token1Price(): Price<Token, Token>;
|
|
23
|
+
/**
|
|
24
|
+
* Return the price of the given token in terms of the other token in the pair.
|
|
25
|
+
* @param token token to return price of
|
|
26
|
+
*/
|
|
27
|
+
priceOf(token: Token): Price<Token, Token>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the chain ID of the tokens in the pair.
|
|
30
|
+
*/
|
|
31
|
+
get chainId(): number;
|
|
32
|
+
get token0(): Token;
|
|
33
|
+
get token1(): Token;
|
|
34
|
+
get reserve0(): CurrencyAmount<Token>;
|
|
35
|
+
get reserve1(): CurrencyAmount<Token>;
|
|
36
|
+
reserveOf(token: Token): CurrencyAmount<Token>;
|
|
37
|
+
getOutputAmount(inputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, Pair];
|
|
38
|
+
getInputAmount(outputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, Pair];
|
|
39
|
+
getLiquidityMinted(totalSupply: CurrencyAmount<Token>, tokenAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>): CurrencyAmount<Token>;
|
|
40
|
+
getLiquidityValue(token: Token, totalSupply: CurrencyAmount<Token>, liquidity: CurrencyAmount<Token>, feeOn?: boolean, kLast?: BigintIsh): CurrencyAmount<Token>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BigintIsh } from '../types';
|
|
2
|
+
import { Fraction } from './Fraction';
|
|
3
|
+
import { Rounding } from '../enums';
|
|
4
|
+
export declare class Percent extends Fraction {
|
|
5
|
+
/**
|
|
6
|
+
* This boolean prevents a fraction from being interpreted as a Percent
|
|
7
|
+
*/
|
|
8
|
+
readonly isPercent: true;
|
|
9
|
+
add(other: Fraction | BigintIsh): Percent;
|
|
10
|
+
subtract(other: Fraction | BigintIsh): Percent;
|
|
11
|
+
multiply(other: Fraction | BigintIsh): Percent;
|
|
12
|
+
divide(other: Fraction | BigintIsh): Percent;
|
|
13
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
14
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BigintIsh } from '../types';
|
|
2
|
+
import { Currency } from './Currency';
|
|
3
|
+
import { CurrencyAmount } from './CurrencyAmount';
|
|
4
|
+
import { Fraction } from './Fraction';
|
|
5
|
+
import { Rounding } from '../enums';
|
|
6
|
+
export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
|
|
7
|
+
readonly baseCurrency: TBase;
|
|
8
|
+
readonly quoteCurrency: TQuote;
|
|
9
|
+
readonly scalar: Fraction;
|
|
10
|
+
/**
|
|
11
|
+
* Construct a price, either with the base and quote currency amount, or the
|
|
12
|
+
* @param args
|
|
13
|
+
*/
|
|
14
|
+
constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
|
|
15
|
+
baseAmount: CurrencyAmount<TBase>;
|
|
16
|
+
quoteAmount: CurrencyAmount<TQuote>;
|
|
17
|
+
}]);
|
|
18
|
+
/**
|
|
19
|
+
* Flip the price, switching the base and quote currency
|
|
20
|
+
*/
|
|
21
|
+
invert(): Price<TQuote, TBase>;
|
|
22
|
+
/**
|
|
23
|
+
* 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
|
|
24
|
+
* @param other the other price
|
|
25
|
+
*/
|
|
26
|
+
multiply<TOtherQuote extends Currency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
|
|
27
|
+
/**
|
|
28
|
+
* Return the amount of quote currency corresponding to a given amount of the base currency
|
|
29
|
+
* @param currencyAmount the amount of base currency to quote against the price
|
|
30
|
+
*/
|
|
31
|
+
quote(currencyAmount: CurrencyAmount<TBase>): CurrencyAmount<TQuote>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the value scaled by decimals for formatting
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private get adjustedForDecimals();
|
|
37
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
38
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
39
|
+
}
|