@qidao/sdk 5.0.0-canary.117
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 +21 -0
- package/README.md +53 -0
- 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/Fraction.d.ts +25 -0
- 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 +33 -0
- package/dist/entities/Trade.d.ts +107 -0
- package/dist/entities/eip712.d.ts +78 -0
- package/dist/entities/index.d.ts +14 -0
- package/dist/enums/ChainId.d.ts +31 -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/errors.d.ts +16 -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 +12 -0
- package/dist/index.js +8 -0
- 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/router.d.ts +68 -0
- package/dist/sdk.cjs.development.js +5303 -0
- package/dist/sdk.cjs.development.js.map +1 -0
- package/dist/sdk.cjs.production.min.js +2 -0
- package/dist/sdk.cjs.production.min.js.map +1 -0
- package/dist/sdk.esm.js +5164 -0
- package/dist/sdk.esm.js.map +1 -0
- 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 +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Noah Zinsmeister
|
|
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,53 @@
|
|
|
1
|
+
# Sushiswap SDK
|
|
2
|
+
|
|
3
|
+
In-depth documentation on this SDK is available at [uniswap.org](https://uniswap.org/docs/v2/SDK/getting-started/).
|
|
4
|
+
|
|
5
|
+
This modifies uniswap-sdk's UniswapV2Factory address. The new address for sushiswap is `0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac`.
|
|
6
|
+
|
|
7
|
+
## Running tests
|
|
8
|
+
|
|
9
|
+
To run the tests, follow these steps. You must have at least node v10 and [yarn](https://yarnpkg.com/) installed.
|
|
10
|
+
|
|
11
|
+
First clone the repository:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
git clone https://github.com/sushiswap/sushiswap-sdk.git
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Move into the sushiswap-sdk working directory
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
cd sushiswap-sdk/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Install dependencies
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
yarn install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Run tests
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
yarn test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You should see output like the following:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
yarn run v1.22.4
|
|
39
|
+
$ tsdx test
|
|
40
|
+
PASS test/constants.test.ts
|
|
41
|
+
PASS test/pair.test.ts
|
|
42
|
+
PASS test/fraction.test.ts
|
|
43
|
+
PASS test/miscellaneous.test.ts
|
|
44
|
+
PASS test/entities.test.ts
|
|
45
|
+
PASS test/trade.test.ts
|
|
46
|
+
|
|
47
|
+
Test Suites: 1 skipped, 6 passed, 6 of 7 total
|
|
48
|
+
Tests: 3 skipped, 82 passed, 85 total
|
|
49
|
+
Snapshots: 0 total
|
|
50
|
+
Time: 5.091s
|
|
51
|
+
Ran all test suites.
|
|
52
|
+
✨ Done in 6.61s.
|
|
53
|
+
```
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BigintIsh } from '../types';
|
|
2
|
+
import JSBI from 'jsbi';
|
|
3
|
+
import { Rounding } from '../enums';
|
|
4
|
+
export declare class Fraction {
|
|
5
|
+
readonly numerator: JSBI;
|
|
6
|
+
readonly denominator: JSBI;
|
|
7
|
+
constructor(numerator: BigintIsh, denominator?: BigintIsh);
|
|
8
|
+
private static tryParseFraction;
|
|
9
|
+
get quotient(): JSBI;
|
|
10
|
+
get remainder(): Fraction;
|
|
11
|
+
invert(): Fraction;
|
|
12
|
+
add(other: Fraction | BigintIsh): Fraction;
|
|
13
|
+
subtract(other: Fraction | BigintIsh): Fraction;
|
|
14
|
+
lessThan(other: Fraction | BigintIsh): boolean;
|
|
15
|
+
equalTo(other: Fraction | BigintIsh): boolean;
|
|
16
|
+
greaterThan(other: Fraction | BigintIsh): boolean;
|
|
17
|
+
multiply(other: Fraction | BigintIsh): Fraction;
|
|
18
|
+
divide(other: Fraction | BigintIsh): Fraction;
|
|
19
|
+
toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
|
|
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;
|
|
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
|
+
}
|