monad-v3-sdk 2.1.0
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 +1 -0
- package/dist/abis/algebraPositionManager.d.ts +1083 -0
- package/dist/abis/algebraSwapRouter.d.ts +499 -0
- package/dist/abis/index.d.ts +3 -0
- package/dist/abis/selfPermit.d.ts +121 -0
- package/dist/classes/index.d.ts +3 -0
- package/dist/classes/nonfungiblePositionManager.d.ts +145 -0
- package/dist/classes/selfPermit.d.ts +22 -0
- package/dist/classes/swapRouter.d.ts +67 -0
- package/dist/constants/addresses.d.ts +6 -0
- package/dist/constants/chainIds.d.ts +3 -0
- package/dist/constants/constants.d.ts +3 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/internalConstants.d.ts +7 -0
- package/dist/entities/AbstractCurrency.d.ts +48 -0
- package/dist/entities/Currency.d.ts +3 -0
- package/dist/entities/CurrencyAmount.d.ts +32 -0
- package/dist/entities/ExtendedNative.d.ts +7 -0
- package/dist/entities/Fraction.d.ts +25 -0
- package/dist/entities/Native.d.ts +13 -0
- package/dist/entities/NativeCurrency.d.ts +8 -0
- package/dist/entities/Percent.d.ts +16 -0
- package/dist/entities/Price.d.ts +39 -0
- package/dist/entities/Token.d.ts +32 -0
- package/dist/entities/index.d.ts +17 -0
- package/dist/entities/pool.d.ts +86 -0
- package/dist/entities/position.d.ts +135 -0
- package/dist/entities/route.d.ts +28 -0
- package/dist/entities/tick.d.ts +13 -0
- package/dist/entities/tickDataProvider.d.ts +31 -0
- package/dist/entities/tickListDataProvider.d.ts +15 -0
- package/dist/entities/trade.d.ts +224 -0
- package/dist/entities/wnative.d.ts +7 -0
- package/dist/enums/bound.d.ts +4 -0
- package/dist/enums/field.d.ts +4 -0
- package/dist/enums/index.d.ts +4 -0
- package/dist/enums/rounding.d.ts +5 -0
- package/dist/enums/tradeType.d.ts +4 -0
- package/dist/functions/index.d.ts +5 -0
- package/dist/functions/maxAmountSpend.d.ts +7 -0
- package/dist/functions/mint.d.ts +3 -0
- package/dist/functions/retry.d.ts +22 -0
- package/dist/functions/tryParseAmount.d.ts +3 -0
- package/dist/functions/unwrappedToken.d.ts +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/monad-v3-sdk.cjs.development.js +5458 -0
- package/dist/monad-v3-sdk.cjs.development.js.map +1 -0
- package/dist/monad-v3-sdk.cjs.production.min.js +2 -0
- package/dist/monad-v3-sdk.cjs.production.min.js.map +1 -0
- package/dist/monad-v3-sdk.esm.js +5395 -0
- package/dist/monad-v3-sdk.esm.js.map +1 -0
- package/dist/types/BigIntish.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/calldata.d.ts +20 -0
- package/dist/utils/chunkArray.d.ts +2 -0
- package/dist/utils/computePoolAddress.d.ts +28 -0
- package/dist/utils/computeSurroundingTicks.d.ts +2 -0
- package/dist/utils/encodeRouteToPath.d.ts +8 -0
- package/dist/utils/encodeSqrtRatioX96.d.ts +9 -0
- package/dist/utils/format.d.ts +14 -0
- package/dist/utils/formatTickPrice.d.ts +5 -0
- package/dist/utils/fullMath.d.ts +7 -0
- package/dist/utils/getRatio.d.ts +2 -0
- package/dist/utils/getTickToPrice.d.ts +2 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/isSorted.d.ts +7 -0
- package/dist/utils/liquidityMath.d.ts +7 -0
- package/dist/utils/maxLiquidityForAmounts.d.ts +14 -0
- package/dist/utils/mostSignificantBit.d.ts +2 -0
- package/dist/utils/nearestUsableTick.d.ts +6 -0
- package/dist/utils/priceTickConversions.d.ts +16 -0
- package/dist/utils/sortedInsert.d.ts +1 -0
- package/dist/utils/sqrt.d.ts +7 -0
- package/dist/utils/sqrtPriceMath.d.ts +12 -0
- package/dist/utils/stringToColour.d.ts +5 -0
- package/dist/utils/swapMath.d.ts +7 -0
- package/dist/utils/tickList.d.ts +22 -0
- package/dist/utils/tickMath.d.ts +33 -0
- package/dist/utils/validateAndParseAddress.d.ts +1 -0
- package/package.json +62 -0
@@ -0,0 +1,145 @@
|
|
1
|
+
import { BigintIsh } from '../types/BigIntish';
|
2
|
+
import { Currency } from '../entities/Currency';
|
3
|
+
import { CurrencyAmount } from '../entities/CurrencyAmount';
|
4
|
+
import { Percent } from '../entities/Percent';
|
5
|
+
import NativeCurrency from '../entities/NativeCurrency';
|
6
|
+
import { Position } from '../entities/position';
|
7
|
+
import { MethodParameters } from '../utils/calldata';
|
8
|
+
import { Interface } from '@ethersproject/abi';
|
9
|
+
import { PermitOptions, SelfPermit } from './selfPermit';
|
10
|
+
import { Pool } from '../entities/pool';
|
11
|
+
export declare const MaxUint128: string;
|
12
|
+
export interface MintSpecificOptions {
|
13
|
+
/**
|
14
|
+
* The account that should receive the minted NFT.
|
15
|
+
*/
|
16
|
+
recipient: string;
|
17
|
+
/**
|
18
|
+
* Creates pool if not initialized before mint.
|
19
|
+
*/
|
20
|
+
createPool?: boolean;
|
21
|
+
}
|
22
|
+
export interface IncreaseSpecificOptions {
|
23
|
+
/**
|
24
|
+
* Indicates the ID of the position to increase liquidity for.
|
25
|
+
*/
|
26
|
+
tokenId: BigintIsh;
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Options for producing the calldata to add liquidity.
|
30
|
+
*/
|
31
|
+
export interface CommonAddLiquidityOptions {
|
32
|
+
/**
|
33
|
+
* How much the pool price is allowed to move.
|
34
|
+
*/
|
35
|
+
slippageTolerance: Percent;
|
36
|
+
/**
|
37
|
+
* When the transaction expires, in epoch seconds.
|
38
|
+
*/
|
39
|
+
deadline: BigintIsh;
|
40
|
+
/**
|
41
|
+
* Pool Deployer address. ZERO_ADDRESS if base pool
|
42
|
+
*/
|
43
|
+
deployer?: string;
|
44
|
+
/**
|
45
|
+
* Whether to spend ether. If true, one of the pool tokens must be WETH, by default false
|
46
|
+
*/
|
47
|
+
useNative?: NativeCurrency;
|
48
|
+
/**
|
49
|
+
* The optional permit parameters for spending token0
|
50
|
+
*/
|
51
|
+
token0Permit?: PermitOptions;
|
52
|
+
/**
|
53
|
+
* The optional permit parameters for spending token1
|
54
|
+
*/
|
55
|
+
token1Permit?: PermitOptions;
|
56
|
+
}
|
57
|
+
export declare type MintOptions = CommonAddLiquidityOptions & MintSpecificOptions;
|
58
|
+
export declare type IncreaseOptions = CommonAddLiquidityOptions & IncreaseSpecificOptions;
|
59
|
+
export declare type AddLiquidityOptions = MintOptions | IncreaseOptions;
|
60
|
+
export interface CollectOptions {
|
61
|
+
/**
|
62
|
+
* Indicates the ID of the position to collect for.
|
63
|
+
*/
|
64
|
+
tokenId: BigintIsh;
|
65
|
+
/**
|
66
|
+
* Expected value of tokensOwed0, including as-of-yet-unaccounted-for fees/liquidity value to be burned
|
67
|
+
*/
|
68
|
+
expectedCurrencyOwed0: CurrencyAmount<Currency>;
|
69
|
+
/**
|
70
|
+
* Expected value of tokensOwed1, including as-of-yet-unaccounted-for fees/liquidity value to be burned
|
71
|
+
*/
|
72
|
+
expectedCurrencyOwed1: CurrencyAmount<Currency>;
|
73
|
+
/**
|
74
|
+
* The account that should receive the tokens.
|
75
|
+
*/
|
76
|
+
recipient: string;
|
77
|
+
}
|
78
|
+
export interface NFTPermitOptions {
|
79
|
+
v: 0 | 1 | 27 | 28;
|
80
|
+
r: string;
|
81
|
+
s: string;
|
82
|
+
deadline: BigintIsh;
|
83
|
+
spender: string;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Options for producing the calldata to exit a position.
|
87
|
+
*/
|
88
|
+
export interface RemoveLiquidityOptions {
|
89
|
+
/**
|
90
|
+
* The ID of the token to exit
|
91
|
+
*/
|
92
|
+
tokenId: BigintIsh;
|
93
|
+
/**
|
94
|
+
* The percentage of position liquidity to exit.
|
95
|
+
*/
|
96
|
+
liquidityPercentage: Percent;
|
97
|
+
/**
|
98
|
+
* How much the pool price is allowed to move.
|
99
|
+
*/
|
100
|
+
slippageTolerance: Percent;
|
101
|
+
/**
|
102
|
+
* When the transaction expires, in epoch seconds.
|
103
|
+
*/
|
104
|
+
deadline: BigintIsh;
|
105
|
+
/**
|
106
|
+
* Whether the NFT should be burned if the entire position is being exited, by default false.
|
107
|
+
*/
|
108
|
+
burnToken?: boolean;
|
109
|
+
/**
|
110
|
+
* The optional permit of the token ID being exited, in case the exit transaction is being sent by an account that does not own the NFT
|
111
|
+
*/
|
112
|
+
permit?: NFTPermitOptions;
|
113
|
+
/**
|
114
|
+
* Parameters to be passed on to collect
|
115
|
+
*/
|
116
|
+
collectOptions: Omit<CollectOptions, 'tokenId'>;
|
117
|
+
}
|
118
|
+
export declare abstract class NonfungiblePositionManager extends SelfPermit {
|
119
|
+
static INTERFACE: Interface;
|
120
|
+
/**
|
121
|
+
* Cannot be constructed.
|
122
|
+
*/
|
123
|
+
private constructor();
|
124
|
+
static createCallParameters(pool: Pool, deployer?: string): MethodParameters;
|
125
|
+
static addCallParameters(position: Position, options: AddLiquidityOptions): {
|
126
|
+
calldata: string[];
|
127
|
+
value: string;
|
128
|
+
};
|
129
|
+
static collectCallParameters(options: CollectOptions): {
|
130
|
+
calldata: string[];
|
131
|
+
value: string;
|
132
|
+
};
|
133
|
+
/**
|
134
|
+
* Produces the calldata for completely or partially exiting a position
|
135
|
+
* @param position The position to exit
|
136
|
+
* @param options Additional information necessary for generating the calldata
|
137
|
+
* @returns The call parameters
|
138
|
+
*/
|
139
|
+
static removeCallParameters(position: Position, options: RemoveLiquidityOptions): {
|
140
|
+
calldata: string[];
|
141
|
+
value: string;
|
142
|
+
};
|
143
|
+
private static encodeCreate;
|
144
|
+
private static encodeCollect;
|
145
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { BigintIsh } from '../types/BigIntish';
|
2
|
+
import { Token } from '../entities/Token';
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
4
|
+
export interface StandardPermitArguments {
|
5
|
+
v: 0 | 1 | 27 | 28;
|
6
|
+
r: string;
|
7
|
+
s: string;
|
8
|
+
amount: BigintIsh;
|
9
|
+
deadline: BigintIsh;
|
10
|
+
}
|
11
|
+
export interface AllowedPermitArguments {
|
12
|
+
v: 0 | 1 | 27 | 28;
|
13
|
+
r: string;
|
14
|
+
s: string;
|
15
|
+
nonce: BigintIsh;
|
16
|
+
expiry: BigintIsh;
|
17
|
+
}
|
18
|
+
export declare type PermitOptions = StandardPermitArguments | AllowedPermitArguments;
|
19
|
+
export declare abstract class SelfPermit {
|
20
|
+
static INTERFACE: Interface;
|
21
|
+
protected static encodePermit(token: Token, options: PermitOptions): string;
|
22
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
2
|
+
import { BigintIsh } from '../types/BigIntish';
|
3
|
+
import { Currency } from '../entities/Currency';
|
4
|
+
import { Percent } from '../entities/Percent';
|
5
|
+
import { TradeType } from '../enums/tradeType';
|
6
|
+
import { Trade } from '../entities/trade';
|
7
|
+
import { PermitOptions, SelfPermit } from './selfPermit';
|
8
|
+
import { MethodParameters } from '../utils/calldata';
|
9
|
+
export interface FeeOptions {
|
10
|
+
/**
|
11
|
+
* The percent of the output that will be taken as a fee.
|
12
|
+
*/
|
13
|
+
fee: Percent;
|
14
|
+
/**
|
15
|
+
* The recipient of the fee.
|
16
|
+
*/
|
17
|
+
recipient: string;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Options for producing the arguments to send calls to the router.
|
21
|
+
*/
|
22
|
+
export interface SwapOptions {
|
23
|
+
/**
|
24
|
+
* How much the execution price is allowed to move unfavorably from the trade execution price.
|
25
|
+
*/
|
26
|
+
slippageTolerance: Percent;
|
27
|
+
/**
|
28
|
+
* The account that should receive the output.
|
29
|
+
*/
|
30
|
+
recipient: string;
|
31
|
+
/**
|
32
|
+
* When the transaction expires, in epoch seconds.
|
33
|
+
*/
|
34
|
+
deadline: BigintIsh;
|
35
|
+
/**
|
36
|
+
* Deflationary token.
|
37
|
+
*/
|
38
|
+
feeOnTransfer: boolean;
|
39
|
+
/**
|
40
|
+
* The optional permit parameters for spending the input.
|
41
|
+
*/
|
42
|
+
inputTokenPermit?: PermitOptions;
|
43
|
+
/**
|
44
|
+
* The optional price limit for the trade.
|
45
|
+
*/
|
46
|
+
sqrtPriceLimitX96?: BigintIsh;
|
47
|
+
/**
|
48
|
+
* Optional information for taking a fee on output.
|
49
|
+
*/
|
50
|
+
fee?: FeeOptions;
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Represents the SwapRouter, and has static methods for helping execute trades.
|
54
|
+
*/
|
55
|
+
export declare abstract class SwapRouter extends SelfPermit {
|
56
|
+
static INTERFACE: Interface;
|
57
|
+
/**
|
58
|
+
* Cannot be constructed.
|
59
|
+
*/
|
60
|
+
private constructor();
|
61
|
+
/**
|
62
|
+
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
|
63
|
+
* @param trade to produce call parameters for
|
64
|
+
* @param options options for the call parameters
|
65
|
+
*/
|
66
|
+
static swapCallParameters(trades: Trade<Currency, Currency, TradeType> | Trade<Currency, Currency, TradeType>[], options: SwapOptions): MethodParameters;
|
67
|
+
}
|
@@ -0,0 +1,48 @@
|
|
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 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.
|
46
|
+
*/
|
47
|
+
abstract get wrapped(): Token;
|
48
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { BigintIsh } from "../types/BigIntish";
|
2
|
+
import { Currency } from './Currency';
|
3
|
+
import { Fraction } from './Fraction';
|
4
|
+
import JSBI from 'jsbi';
|
5
|
+
import { Rounding } from '../enums/rounding';
|
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
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { BigintIsh } from '../types/BigIntish';
|
2
|
+
import JSBI from 'jsbi';
|
3
|
+
import { Rounding } from '../enums/rounding';
|
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,13 @@
|
|
1
|
+
import { Token } from "./Token";
|
2
|
+
import { Currency } from "./Currency";
|
3
|
+
import NativeCurrency from './NativeCurrency';
|
4
|
+
/**
|
5
|
+
* Native is the main usage of a 'native' currency
|
6
|
+
*/
|
7
|
+
export declare class Native extends NativeCurrency {
|
8
|
+
protected constructor(chainId: number, symbol: string, name: string);
|
9
|
+
get wrapped(): Token;
|
10
|
+
private static _naitveCache;
|
11
|
+
static onChain(chainId: number, symbol: string, name: string): Native;
|
12
|
+
equals(other: Currency): boolean;
|
13
|
+
}
|
@@ -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 default abstract class NativeCurrency extends AbstractCurrency {
|
6
|
+
readonly isNative: true;
|
7
|
+
readonly isToken: false;
|
8
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { BigintIsh } from '../types/BigIntish';
|
2
|
+
import { Fraction } from './Fraction';
|
3
|
+
import { Rounding } from '../enums/rounding';
|
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
|
+
constructor(numerator: BigintIsh, denominator?: BigintIsh);
|
10
|
+
add(other: Fraction | BigintIsh): Percent;
|
11
|
+
subtract(other: Fraction | BigintIsh): Percent;
|
12
|
+
multiply(other: Fraction | BigintIsh): Percent;
|
13
|
+
divide(other: Fraction | BigintIsh): Percent;
|
14
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
15
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
16
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { BigintIsh } from '../types/BigIntish';
|
2
|
+
import { Currency } from './Currency';
|
3
|
+
import { CurrencyAmount } from './CurrencyAmount';
|
4
|
+
import { Fraction } from './Fraction';
|
5
|
+
import { Rounding } from '../enums/rounding';
|
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
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { AbstractCurrency } from './AbstractCurrency';
|
2
|
+
import { Currency } from './Currency';
|
3
|
+
/**
|
4
|
+
* Represents an ERC20 token with a unique address and some metadata.
|
5
|
+
*/
|
6
|
+
export declare class Token extends AbstractCurrency {
|
7
|
+
readonly chainId: number;
|
8
|
+
readonly address: string;
|
9
|
+
readonly isNative: false;
|
10
|
+
readonly isToken: true;
|
11
|
+
constructor(chainId: number, address: string, decimals: number, symbol?: string, name?: string);
|
12
|
+
/**
|
13
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
14
|
+
* @param other other token to compare
|
15
|
+
*/
|
16
|
+
equals(other: Currency): boolean;
|
17
|
+
/**
|
18
|
+
* Returns true if the address of this token sorts before the address of the other token
|
19
|
+
* @param other other token to compare
|
20
|
+
* @throws if the tokens have the same address
|
21
|
+
* @throws if the tokens are on different chains
|
22
|
+
*/
|
23
|
+
sortsBefore(other: Token): boolean;
|
24
|
+
/**
|
25
|
+
* Return this token, which does not need to be wrapped
|
26
|
+
*/
|
27
|
+
get wrapped(): Token;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Compares two currencies for equality
|
31
|
+
*/
|
32
|
+
export declare function currencyEquals(currencyA: Currency, currencyB: Currency): boolean;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export * from './pool';
|
2
|
+
export * from './position';
|
3
|
+
export * from './route';
|
4
|
+
export * from './tick';
|
5
|
+
export * from './trade';
|
6
|
+
export * from './tickDataProvider';
|
7
|
+
export * from './tickListDataProvider';
|
8
|
+
export * from './Price';
|
9
|
+
export * from './Token';
|
10
|
+
export * from './Percent';
|
11
|
+
export * from './CurrencyAmount';
|
12
|
+
export * from './Currency';
|
13
|
+
export * from './NativeCurrency';
|
14
|
+
export * from './Native';
|
15
|
+
export * from './Fraction';
|
16
|
+
export * from './ExtendedNative';
|
17
|
+
export * from './wnative';
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import { CurrencyAmount } from './CurrencyAmount';
|
2
|
+
import { Price } from './Price';
|
3
|
+
import { Token } from './Token';
|
4
|
+
import { BigintIsh } from '../types/BigIntish';
|
5
|
+
import JSBI from 'jsbi';
|
6
|
+
import { Tick, TickConstructorArgs } from './tick';
|
7
|
+
import { TickDataProvider } from './tickDataProvider';
|
8
|
+
/**
|
9
|
+
* Represents a V3 pool
|
10
|
+
*/
|
11
|
+
export declare class Pool {
|
12
|
+
readonly token0: Token;
|
13
|
+
readonly token1: Token;
|
14
|
+
readonly fee: number;
|
15
|
+
readonly sqrtRatioX96: JSBI;
|
16
|
+
readonly deployer: string;
|
17
|
+
readonly liquidity: JSBI;
|
18
|
+
readonly tickCurrent: number;
|
19
|
+
readonly tickDataProvider: TickDataProvider;
|
20
|
+
readonly _tickSpacing: number;
|
21
|
+
/**
|
22
|
+
* Construct a pool
|
23
|
+
* @param tokenA One of the tokens in the pool
|
24
|
+
* @param tokenB The other token in the pool
|
25
|
+
* @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
|
26
|
+
* @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0
|
27
|
+
* @param liquidity The current value of in range liquidity
|
28
|
+
* @param tickCurrent The current tick of the pool
|
29
|
+
* @param ticks The current state of the pool ticks or a data provider that can return tick data
|
30
|
+
* @param _tickSpacing The spacing between ticks
|
31
|
+
*/
|
32
|
+
constructor(tokenA: Token, tokenB: Token, fee: number, sqrtRatioX96: BigintIsh, deployer: string, liquidity: BigintIsh, tickCurrent: number, _tickSpacing: number, ticks?: TickDataProvider | (Tick | TickConstructorArgs)[]);
|
33
|
+
private _token0Price?;
|
34
|
+
/**
|
35
|
+
* Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
|
36
|
+
*/
|
37
|
+
get token0Price(): Price<Token, Token>;
|
38
|
+
private _token1Price?;
|
39
|
+
/**
|
40
|
+
* Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
|
41
|
+
*/
|
42
|
+
get token1Price(): Price<Token, Token>;
|
43
|
+
/**
|
44
|
+
* Returns the chain ID of the tokens in the pool.
|
45
|
+
*/
|
46
|
+
get chainId(): number;
|
47
|
+
get tickSpacing(): number;
|
48
|
+
static getAddress(tokenA: Token, tokenB: Token, initCodeHashManualOverride?: string): string;
|
49
|
+
/**
|
50
|
+
* Returns true if the token is either token0 or token1
|
51
|
+
* @param token The token to check
|
52
|
+
* @returns True if token is either token0 or token
|
53
|
+
*/
|
54
|
+
involvesToken(token: Token): boolean;
|
55
|
+
/**
|
56
|
+
* Return the price of the given token in terms of the other token in the pool.
|
57
|
+
* @param token The token to return price of
|
58
|
+
* @returns The price of the given token, in terms of the other.
|
59
|
+
*/
|
60
|
+
priceOf(token: Token): Price<Token, Token>;
|
61
|
+
/**
|
62
|
+
* Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
|
63
|
+
* @param inputAmount The input amount for which to quote the output amount
|
64
|
+
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit
|
65
|
+
* @returns The output amount and the pool with updated state
|
66
|
+
*/
|
67
|
+
getOutputAmount(inputAmount: CurrencyAmount<Token>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Token>, Pool]>;
|
68
|
+
/**
|
69
|
+
* Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
|
70
|
+
* @param outputAmount the output amount for which to quote the input amount
|
71
|
+
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
|
72
|
+
* @returns The input amount and the pool with updated state
|
73
|
+
*/
|
74
|
+
getInputAmount(outputAmount: CurrencyAmount<Token>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Token>, Pool]>;
|
75
|
+
/**
|
76
|
+
* Executes a swap
|
77
|
+
* @param zeroForOne Whether the amount in is token0 or token1
|
78
|
+
* @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
|
79
|
+
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
|
80
|
+
* @returns amountCalculated
|
81
|
+
* @returns sqrtRatioX96
|
82
|
+
* @returns liquidity
|
83
|
+
* @returns tickCurrent
|
84
|
+
*/
|
85
|
+
private swap;
|
86
|
+
}
|