@juiceswapxyz/v4-sdk 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PositionManager.d.ts +169 -0
- package/dist/actionConstants.d.ts +1 -0
- package/dist/entities/index.d.ts +4 -0
- package/dist/entities/pool.d.ts +103 -0
- package/dist/entities/position.d.ts +144 -0
- package/dist/entities/route.d.ts +28 -0
- package/dist/entities/trade.d.ts +220 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/internalConstants.d.ts +46 -0
- package/dist/multicall.d.ts +10 -0
- package/dist/utils/calldata.d.ts +20 -0
- package/dist/utils/currencyMap.d.ts +2 -0
- package/dist/utils/encodeRouteToPath.d.ts +10 -0
- package/dist/utils/hook.d.ts +45 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/pathCurrency.d.ts +4 -0
- package/dist/utils/positionManagerAbi.d.ts +102 -0
- package/dist/utils/priceTickConversions.d.ts +20 -0
- package/dist/utils/sortsBefore.d.ts +2 -0
- package/dist/utils/v4BaseActionsParser.d.ts +45 -0
- package/dist/utils/v4Planner.d.ts +55 -0
- package/dist/utils/v4PositionPlanner.d.ts +12 -0
- package/dist/v4-sdk.cjs.development.js +3511 -0
- package/dist/v4-sdk.cjs.development.js.map +1 -0
- package/dist/v4-sdk.cjs.production.min.js +2 -0
- package/dist/v4-sdk.cjs.production.min.js.map +1 -0
- package/dist/v4-sdk.esm.js +3494 -0
- package/dist/v4-sdk.esm.js.map +1 -0
- package/package.json +3 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import JSBI from 'jsbi';
|
|
2
|
+
export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
|
|
3
|
+
export declare const NEGATIVE_ONE: JSBI;
|
|
4
|
+
export declare const ZERO: JSBI;
|
|
5
|
+
export declare const ONE: JSBI;
|
|
6
|
+
export declare const ONE_ETHER: JSBI;
|
|
7
|
+
export declare const EMPTY_BYTES = "0x";
|
|
8
|
+
export declare const Q96: JSBI;
|
|
9
|
+
export declare const Q192: JSBI;
|
|
10
|
+
export declare const FEE_AMOUNT_LOW = 100;
|
|
11
|
+
export declare const FEE_AMOUNT_MEDIUM = 3000;
|
|
12
|
+
export declare const FEE_AMOUNT_HIGHEST = 10000;
|
|
13
|
+
export declare const TICK_SPACING_TEN = 10;
|
|
14
|
+
export declare const TICK_SPACING_SIXTY = 60;
|
|
15
|
+
export declare const MIN_SLIPPAGE_DECREASE = 0;
|
|
16
|
+
export declare const OPEN_DELTA: import("ethers").BigNumber;
|
|
17
|
+
export declare const SQRT_PRICE_1_1: JSBI;
|
|
18
|
+
export declare const EMPTY_HOOK = "0x0000000000000000000000000000000000000000";
|
|
19
|
+
export declare const NATIVE_NOT_SET = "NATIVE_NOT_SET";
|
|
20
|
+
export declare const ZERO_LIQUIDITY = "ZERO_LIQUIDITY";
|
|
21
|
+
export declare const NO_SQRT_PRICE = "NO_SQRT_PRICE";
|
|
22
|
+
export declare const CANNOT_BURN = "CANNOT_BURN";
|
|
23
|
+
/**
|
|
24
|
+
* Function fragments that exist on the PositionManager contract.
|
|
25
|
+
*/
|
|
26
|
+
export declare enum PositionFunctions {
|
|
27
|
+
INITIALIZE_POOL = "initializePool",
|
|
28
|
+
MODIFY_LIQUIDITIES = "modifyLiquidities",
|
|
29
|
+
PERMIT_BATCH = "0x002a3e3a",
|
|
30
|
+
ERC721PERMIT_PERMIT = "0x0f5730f1"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The default factory enabled fee amounts, denominated in hundredths of bips.
|
|
34
|
+
*/
|
|
35
|
+
export declare enum FeeAmount {
|
|
36
|
+
LOWEST = 100,
|
|
37
|
+
LOW = 500,
|
|
38
|
+
MEDIUM = 3000,
|
|
39
|
+
HIGH = 10000
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The default factory tick spacings by fee amount.
|
|
43
|
+
*/
|
|
44
|
+
export declare const TICK_SPACINGS: {
|
|
45
|
+
[amount in FeeAmount]: number;
|
|
46
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
export declare abstract class Multicall {
|
|
3
|
+
static INTERFACE: Interface;
|
|
4
|
+
/**
|
|
5
|
+
* Cannot be constructed.
|
|
6
|
+
*/
|
|
7
|
+
private constructor();
|
|
8
|
+
static encodeMulticall(calldataList: string | string[]): string;
|
|
9
|
+
static decodeMulticall(encodedCalldata: string): string[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BigintIsh } from '@juiceswapxyz/sdk-core';
|
|
2
|
+
/**
|
|
3
|
+
* Generated method parameters for executing a call.
|
|
4
|
+
*/
|
|
5
|
+
export interface MethodParameters {
|
|
6
|
+
/**
|
|
7
|
+
* The hex encoded calldata to perform the given operation
|
|
8
|
+
*/
|
|
9
|
+
calldata: string;
|
|
10
|
+
/**
|
|
11
|
+
* The amount of ether (wei) to send in hex.
|
|
12
|
+
*/
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Converts a big int to a hex string
|
|
17
|
+
* @param bigintIsh
|
|
18
|
+
* @returns The hex encoded calldata
|
|
19
|
+
*/
|
|
20
|
+
export declare function toHex(bigintIsh: BigintIsh): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Currency } from '@juiceswapxyz/sdk-core';
|
|
2
|
+
import { Route } from '../entities/route';
|
|
3
|
+
export declare type PathKey = {
|
|
4
|
+
intermediateCurrency: string;
|
|
5
|
+
fee: number;
|
|
6
|
+
tickSpacing: number;
|
|
7
|
+
hooks: string;
|
|
8
|
+
hookData: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const encodeRouteToPath: (route: Route<Currency, Currency>, exactOutput?: boolean | undefined) => PathKey[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare type HookPermissions = {
|
|
2
|
+
[key in HookOptions]: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare enum HookOptions {
|
|
5
|
+
AfterRemoveLiquidityReturnsDelta = "afterRemoveLiquidityReturnsDelta",
|
|
6
|
+
AfterAddLiquidityReturnsDelta = "afterAddLiquidityReturnsDelta",
|
|
7
|
+
AfterSwapReturnsDelta = "afterSwapReturnsDelta",
|
|
8
|
+
BeforeSwapReturnsDelta = "beforeSwapReturnsDelta",
|
|
9
|
+
AfterDonate = "afterDonate",
|
|
10
|
+
BeforeDonate = "beforeDonate",
|
|
11
|
+
AfterSwap = "afterSwap",
|
|
12
|
+
BeforeSwap = "beforeSwap",
|
|
13
|
+
AfterRemoveLiquidity = "afterRemoveLiquidity",
|
|
14
|
+
BeforeRemoveLiquidity = "beforeRemoveLiquidity",
|
|
15
|
+
AfterAddLiquidity = "afterAddLiquidity",
|
|
16
|
+
BeforeAddLiquidity = "beforeAddLiquidity",
|
|
17
|
+
AfterInitialize = "afterInitialize",
|
|
18
|
+
BeforeInitialize = "beforeInitialize"
|
|
19
|
+
}
|
|
20
|
+
export declare const hookFlagIndex: {
|
|
21
|
+
afterRemoveLiquidityReturnsDelta: number;
|
|
22
|
+
afterAddLiquidityReturnsDelta: number;
|
|
23
|
+
afterSwapReturnsDelta: number;
|
|
24
|
+
beforeSwapReturnsDelta: number;
|
|
25
|
+
afterDonate: number;
|
|
26
|
+
beforeDonate: number;
|
|
27
|
+
afterSwap: number;
|
|
28
|
+
beforeSwap: number;
|
|
29
|
+
afterRemoveLiquidity: number;
|
|
30
|
+
beforeRemoveLiquidity: number;
|
|
31
|
+
afterAddLiquidity: number;
|
|
32
|
+
beforeAddLiquidity: number;
|
|
33
|
+
afterInitialize: number;
|
|
34
|
+
beforeInitialize: number;
|
|
35
|
+
};
|
|
36
|
+
export declare class Hook {
|
|
37
|
+
static permissions(address: string): HookPermissions;
|
|
38
|
+
static hasPermission(address: string, hookOption: HookOptions): boolean;
|
|
39
|
+
static hasInitializePermissions(address: string): boolean;
|
|
40
|
+
static hasLiquidityPermissions(address: string): boolean;
|
|
41
|
+
static hasSwapPermissions(address: string): boolean;
|
|
42
|
+
static hasDonatePermissions(address: string): boolean;
|
|
43
|
+
private static _hasPermission;
|
|
44
|
+
private static _checkAddress;
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './encodeRouteToPath';
|
|
2
|
+
export * from './v4Planner';
|
|
3
|
+
export * from './v4PositionPlanner';
|
|
4
|
+
export * from './calldata';
|
|
5
|
+
export * from './v4BaseActionsParser';
|
|
6
|
+
export * from './currencyMap';
|
|
7
|
+
export * from './encodeRouteToPath';
|
|
8
|
+
export * from './pathCurrency';
|
|
9
|
+
export * from './priceTickConversions';
|
|
10
|
+
export * from './sortsBefore';
|
|
11
|
+
export * from './hook';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Currency, CurrencyAmount } from '@juiceswapxyz/sdk-core';
|
|
2
|
+
import { Pool } from '../entities/pool';
|
|
3
|
+
export declare function amountWithPathCurrency(amount: CurrencyAmount<Currency>, pool: Pool): CurrencyAmount<Currency>;
|
|
4
|
+
export declare function getPathCurrency(currency: Currency, pool: Pool): Currency;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export declare const positionManagerAbi: ({
|
|
2
|
+
type: string;
|
|
3
|
+
inputs: {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
internalType: string;
|
|
7
|
+
}[];
|
|
8
|
+
stateMutability: string;
|
|
9
|
+
name?: undefined;
|
|
10
|
+
outputs?: undefined;
|
|
11
|
+
anonymous?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
type: string;
|
|
14
|
+
stateMutability: string;
|
|
15
|
+
inputs?: undefined;
|
|
16
|
+
name?: undefined;
|
|
17
|
+
outputs?: undefined;
|
|
18
|
+
anonymous?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
type: string;
|
|
21
|
+
name: string;
|
|
22
|
+
inputs: {
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
internalType: string;
|
|
26
|
+
}[];
|
|
27
|
+
outputs: ({
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
internalType: string;
|
|
31
|
+
components: {
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
internalType: string;
|
|
35
|
+
}[];
|
|
36
|
+
} | {
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
internalType: string;
|
|
40
|
+
components?: undefined;
|
|
41
|
+
})[];
|
|
42
|
+
stateMutability: string;
|
|
43
|
+
anonymous?: undefined;
|
|
44
|
+
} | {
|
|
45
|
+
type: string;
|
|
46
|
+
name: string;
|
|
47
|
+
inputs: ({
|
|
48
|
+
name: string;
|
|
49
|
+
type: string;
|
|
50
|
+
internalType: string;
|
|
51
|
+
components?: undefined;
|
|
52
|
+
} | {
|
|
53
|
+
name: string;
|
|
54
|
+
type: string;
|
|
55
|
+
internalType: string;
|
|
56
|
+
components: ({
|
|
57
|
+
name: string;
|
|
58
|
+
type: string;
|
|
59
|
+
internalType: string;
|
|
60
|
+
components: {
|
|
61
|
+
name: string;
|
|
62
|
+
type: string;
|
|
63
|
+
internalType: string;
|
|
64
|
+
}[];
|
|
65
|
+
} | {
|
|
66
|
+
name: string;
|
|
67
|
+
type: string;
|
|
68
|
+
internalType: string;
|
|
69
|
+
components?: undefined;
|
|
70
|
+
})[];
|
|
71
|
+
})[];
|
|
72
|
+
outputs: {
|
|
73
|
+
name: string;
|
|
74
|
+
type: string;
|
|
75
|
+
internalType: string;
|
|
76
|
+
}[];
|
|
77
|
+
stateMutability: string;
|
|
78
|
+
anonymous?: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
type: string;
|
|
81
|
+
name: string;
|
|
82
|
+
inputs: {
|
|
83
|
+
name: string;
|
|
84
|
+
type: string;
|
|
85
|
+
indexed: boolean;
|
|
86
|
+
internalType: string;
|
|
87
|
+
}[];
|
|
88
|
+
anonymous: boolean;
|
|
89
|
+
stateMutability?: undefined;
|
|
90
|
+
outputs?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
type: string;
|
|
93
|
+
name: string;
|
|
94
|
+
inputs: {
|
|
95
|
+
name: string;
|
|
96
|
+
type: string;
|
|
97
|
+
internalType: string;
|
|
98
|
+
}[];
|
|
99
|
+
stateMutability?: undefined;
|
|
100
|
+
outputs?: undefined;
|
|
101
|
+
anonymous?: undefined;
|
|
102
|
+
})[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Price, Currency } from '@juiceswapxyz/sdk-core';
|
|
2
|
+
/**
|
|
3
|
+
* This library is the almost the same as v3-sdk priceTickConversion except
|
|
4
|
+
* that it accepts a Currency type instead of a Token type,
|
|
5
|
+
* and thus uses some helper functions defined for the Currency type over the Token type.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Returns a price object corresponding to the input tick and the base/quote token
|
|
9
|
+
* Inputs must be tokens because the address order is used to interpret the price represented by the tick
|
|
10
|
+
* @param baseToken the base token of the price
|
|
11
|
+
* @param quoteToken the quote token of the price
|
|
12
|
+
* @param tick the tick for which to return the price
|
|
13
|
+
*/
|
|
14
|
+
export declare function tickToPrice(baseCurrency: Currency, quoteCurrency: Currency, tick: number): Price<Currency, Currency>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the first tick for which the given price is greater than or equal to the tick price
|
|
17
|
+
* @param price for which to return the closest tick that represents a price less than or equal to the input price,
|
|
18
|
+
* i.e. the price of the returned tick is less than or equal to the input price
|
|
19
|
+
*/
|
|
20
|
+
export declare function priceToClosestTick(price: Price<Currency, Currency>): number;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { PoolKey } from '../entities/pool';
|
|
2
|
+
import { PathKey } from './encodeRouteToPath';
|
|
3
|
+
import { Actions } from './v4Planner';
|
|
4
|
+
export declare type Param = {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly value: any;
|
|
7
|
+
};
|
|
8
|
+
export declare type V4RouterAction = {
|
|
9
|
+
readonly actionName: string;
|
|
10
|
+
readonly actionType: Actions;
|
|
11
|
+
readonly params: readonly Param[];
|
|
12
|
+
};
|
|
13
|
+
export declare type V4RouterCall = {
|
|
14
|
+
readonly actions: readonly V4RouterAction[];
|
|
15
|
+
};
|
|
16
|
+
export declare type SwapExactInSingle = {
|
|
17
|
+
readonly poolKey: PoolKey;
|
|
18
|
+
readonly zeroForOne: boolean;
|
|
19
|
+
readonly amountIn: string;
|
|
20
|
+
readonly amountOutMinimum: string;
|
|
21
|
+
readonly hookData: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type SwapExactIn = {
|
|
24
|
+
readonly currencyIn: string;
|
|
25
|
+
readonly path: readonly PathKey[];
|
|
26
|
+
readonly amountIn: string;
|
|
27
|
+
readonly amountOutMinimum: string;
|
|
28
|
+
};
|
|
29
|
+
export declare type SwapExactOutSingle = {
|
|
30
|
+
readonly poolKey: PoolKey;
|
|
31
|
+
readonly zeroForOne: boolean;
|
|
32
|
+
readonly amountOut: string;
|
|
33
|
+
readonly amountInMaximum: string;
|
|
34
|
+
readonly hookData: string;
|
|
35
|
+
};
|
|
36
|
+
export declare type SwapExactOut = {
|
|
37
|
+
readonly currencyOut: string;
|
|
38
|
+
readonly path: readonly PathKey[];
|
|
39
|
+
readonly amountOut: string;
|
|
40
|
+
readonly amountInMaximum: string;
|
|
41
|
+
};
|
|
42
|
+
export declare abstract class V4BaseActionsParser {
|
|
43
|
+
static parseCalldata(calldata: string): V4RouterCall;
|
|
44
|
+
private static getActions;
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { Currency, Percent, TradeType } from '@juiceswapxyz/sdk-core';
|
|
3
|
+
import { Trade } from '../entities/trade';
|
|
4
|
+
/**
|
|
5
|
+
* Actions
|
|
6
|
+
* @description Constants that define what action to perform
|
|
7
|
+
* Not all actions are supported yet.
|
|
8
|
+
* @enum {number}
|
|
9
|
+
*/
|
|
10
|
+
export declare enum Actions {
|
|
11
|
+
INCREASE_LIQUIDITY = 0,
|
|
12
|
+
DECREASE_LIQUIDITY = 1,
|
|
13
|
+
MINT_POSITION = 2,
|
|
14
|
+
BURN_POSITION = 3,
|
|
15
|
+
SWAP_EXACT_IN_SINGLE = 6,
|
|
16
|
+
SWAP_EXACT_IN = 7,
|
|
17
|
+
SWAP_EXACT_OUT_SINGLE = 8,
|
|
18
|
+
SWAP_EXACT_OUT = 9,
|
|
19
|
+
SETTLE = 11,
|
|
20
|
+
SETTLE_ALL = 12,
|
|
21
|
+
SETTLE_PAIR = 13,
|
|
22
|
+
TAKE = 14,
|
|
23
|
+
TAKE_ALL = 15,
|
|
24
|
+
TAKE_PORTION = 16,
|
|
25
|
+
TAKE_PAIR = 17,
|
|
26
|
+
CLOSE_CURRENCY = 18,
|
|
27
|
+
SWEEP = 20,
|
|
28
|
+
UNWRAP = 22
|
|
29
|
+
}
|
|
30
|
+
export declare enum Subparser {
|
|
31
|
+
V4SwapExactInSingle = 0,
|
|
32
|
+
V4SwapExactIn = 1,
|
|
33
|
+
V4SwapExactOutSingle = 2,
|
|
34
|
+
V4SwapExactOut = 3,
|
|
35
|
+
PoolKey = 4
|
|
36
|
+
}
|
|
37
|
+
export declare type ParamType = {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly type: string;
|
|
40
|
+
readonly subparser?: Subparser;
|
|
41
|
+
};
|
|
42
|
+
export declare const V4_BASE_ACTIONS_ABI_DEFINITION: {
|
|
43
|
+
[key in Actions]: readonly ParamType[];
|
|
44
|
+
};
|
|
45
|
+
export declare class V4Planner {
|
|
46
|
+
actions: string;
|
|
47
|
+
params: string[];
|
|
48
|
+
constructor();
|
|
49
|
+
addAction(type: Actions, parameters: any[]): V4Planner;
|
|
50
|
+
addTrade(trade: Trade<Currency, Currency, TradeType>, slippageTolerance?: Percent): V4Planner;
|
|
51
|
+
addSettle(currency: Currency, payerIsUser: boolean, amount?: BigNumber): V4Planner;
|
|
52
|
+
addTake(currency: Currency, recipient: string, amount?: BigNumber): V4Planner;
|
|
53
|
+
addUnwrap(amount: BigNumber): V4Planner;
|
|
54
|
+
finalize(): string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { V4Planner } from './v4Planner';
|
|
2
|
+
import { Pool } from '../entities';
|
|
3
|
+
import { BigintIsh, Currency } from '@juiceswapxyz/sdk-core';
|
|
4
|
+
export declare class V4PositionPlanner extends V4Planner {
|
|
5
|
+
addMint(pool: Pool, tickLower: number, tickUpper: number, liquidity: BigintIsh, amount0Max: BigintIsh, amount1Max: BigintIsh, owner: string, hookData?: string): void;
|
|
6
|
+
addIncrease(tokenId: BigintIsh, liquidity: BigintIsh, amount0Max: BigintIsh, amount1Max: BigintIsh, hookData?: string): void;
|
|
7
|
+
addDecrease(tokenId: BigintIsh, liquidity: BigintIsh, amount0Min: BigintIsh, amount1Min: BigintIsh, hookData?: string): void;
|
|
8
|
+
addBurn(tokenId: BigintIsh, amount0Min: BigintIsh, amount1Min: BigintIsh, hookData?: string): void;
|
|
9
|
+
addSettlePair(currency0: Currency, currency1: Currency): void;
|
|
10
|
+
addTakePair(currency0: Currency, currency1: Currency, recipient: string): void;
|
|
11
|
+
addSweep(currency: Currency, to: string): void;
|
|
12
|
+
}
|