@centurion_project/v3-sdk 3.30.0-ctn.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 +13 -0
- package/dist/cjs/src/constants.d.ts +23 -0
- package/dist/cjs/src/constants.js +44 -0
- package/dist/cjs/src/constants.js.map +1 -0
- package/dist/cjs/src/entities/index.d.ts +7 -0
- package/dist/cjs/src/entities/index.js +11 -0
- package/dist/cjs/src/entities/index.js.map +1 -0
- package/dist/cjs/src/entities/pool.d.ts +81 -0
- package/dist/cjs/src/entities/pool.js +142 -0
- package/dist/cjs/src/entities/pool.js.map +1 -0
- package/dist/cjs/src/entities/position.d.ts +131 -0
- package/dist/cjs/src/entities/position.js +248 -0
- package/dist/cjs/src/entities/position.js.map +1 -0
- package/dist/cjs/src/entities/route.d.ts +26 -0
- package/dist/cjs/src/entities/route.js +75 -0
- package/dist/cjs/src/entities/route.js.map +1 -0
- package/dist/cjs/src/entities/tick.d.ts +13 -0
- package/dist/cjs/src/entities/tick.js +17 -0
- package/dist/cjs/src/entities/tick.js.map +1 -0
- package/dist/cjs/src/entities/tickDataProvider.d.ts +31 -0
- package/dist/cjs/src/entities/tickDataProvider.js +18 -0
- package/dist/cjs/src/entities/tickDataProvider.js.map +1 -0
- package/dist/cjs/src/entities/tickListDataProvider.d.ts +15 -0
- package/dist/cjs/src/entities/tickListDataProvider.js +23 -0
- package/dist/cjs/src/entities/tickListDataProvider.js.map +1 -0
- package/dist/cjs/src/entities/trade.d.ts +220 -0
- package/dist/cjs/src/entities/trade.js +440 -0
- package/dist/cjs/src/entities/trade.js.map +1 -0
- package/dist/cjs/src/index.d.ts +10 -0
- package/dist/cjs/src/index.js +14 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/internalConstants.d.ts +6 -0
- package/dist/cjs/src/internalConstants.js +13 -0
- package/dist/cjs/src/internalConstants.js.map +1 -0
- package/dist/cjs/src/multicall.d.ts +10 -0
- package/dist/cjs/src/multicall.js +24 -0
- package/dist/cjs/src/multicall.js.map +1 -0
- package/dist/cjs/src/nonfungiblePositionManager.d.ts +159 -0
- package/dist/cjs/src/nonfungiblePositionManager.js +250 -0
- package/dist/cjs/src/nonfungiblePositionManager.js.map +1 -0
- package/dist/cjs/src/payments.d.ts +24 -0
- package/dist/cjs/src/payments.js +56 -0
- package/dist/cjs/src/payments.js.map +1 -0
- package/dist/cjs/src/quoter.d.ts +37 -0
- package/dist/cjs/src/quoter.js +69 -0
- package/dist/cjs/src/quoter.js.map +1 -0
- package/dist/cjs/src/selfPermit.d.ts +25 -0
- package/dist/cjs/src/selfPermit.js +38 -0
- package/dist/cjs/src/selfPermit.js.map +1 -0
- package/dist/cjs/src/staker.d.ts +101 -0
- package/dist/cjs/src/staker.js +129 -0
- package/dist/cjs/src/staker.js.map +1 -0
- package/dist/cjs/src/swapRouter.d.ts +51 -0
- package/dist/cjs/src/swapRouter.js +145 -0
- package/dist/cjs/src/swapRouter.js.map +1 -0
- package/dist/cjs/src/utils/calldata.d.ts +20 -0
- package/dist/cjs/src/utils/calldata.js +20 -0
- package/dist/cjs/src/utils/calldata.js.map +1 -0
- package/dist/cjs/src/utils/computePoolAddress.d.ts +20 -0
- package/dist/cjs/src/utils/computePoolAddress.js +33 -0
- package/dist/cjs/src/utils/computePoolAddress.js.map +1 -0
- package/dist/cjs/src/utils/encodeRouteToPath.d.ts +8 -0
- package/dist/cjs/src/utils/encodeRouteToPath.js +32 -0
- package/dist/cjs/src/utils/encodeRouteToPath.js.map +1 -0
- package/dist/cjs/src/utils/encodeSqrtRatioX96.d.ts +9 -0
- package/dist/cjs/src/utils/encodeSqrtRatioX96.js +20 -0
- package/dist/cjs/src/utils/encodeSqrtRatioX96.js.map +1 -0
- package/dist/cjs/src/utils/fullMath.d.ts +8 -0
- package/dist/cjs/src/utils/fullMath.js +21 -0
- package/dist/cjs/src/utils/fullMath.js.map +1 -0
- package/dist/cjs/src/utils/index.d.ts +18 -0
- package/dist/cjs/src/utils/index.js +22 -0
- package/dist/cjs/src/utils/index.js.map +1 -0
- package/dist/cjs/src/utils/isSorted.d.ts +7 -0
- package/dist/cjs/src/utils/isSorted.js +19 -0
- package/dist/cjs/src/utils/isSorted.js.map +1 -0
- package/dist/cjs/src/utils/liquidityMath.d.ts +8 -0
- package/dist/cjs/src/utils/liquidityMath.js +22 -0
- package/dist/cjs/src/utils/liquidityMath.js.map +1 -0
- package/dist/cjs/src/utils/maxLiquidityForAmounts.d.ts +14 -0
- package/dist/cjs/src/utils/maxLiquidityForAmounts.js +87 -0
- package/dist/cjs/src/utils/maxLiquidityForAmounts.js.map +1 -0
- package/dist/cjs/src/utils/mostSignificantBit.d.ts +2 -0
- package/dist/cjs/src/utils/mostSignificantBit.js +27 -0
- package/dist/cjs/src/utils/mostSignificantBit.js.map +1 -0
- package/dist/cjs/src/utils/nearestUsableTick.d.ts +6 -0
- package/dist/cjs/src/utils/nearestUsableTick.js +25 -0
- package/dist/cjs/src/utils/nearestUsableTick.js.map +1 -0
- package/dist/cjs/src/utils/position.d.ts +8 -0
- package/dist/cjs/src/utils/position.js +21 -0
- package/dist/cjs/src/utils/position.js.map +1 -0
- package/dist/cjs/src/utils/priceTickConversions.d.ts +15 -0
- package/dist/cjs/src/utils/priceTickConversions.js +50 -0
- package/dist/cjs/src/utils/priceTickConversions.js.map +1 -0
- package/dist/cjs/src/utils/sqrtPriceMath.d.ts +13 -0
- package/dist/cjs/src/utils/sqrtPriceMath.js +95 -0
- package/dist/cjs/src/utils/sqrtPriceMath.js.map +1 -0
- package/dist/cjs/src/utils/swapMath.d.ts +9 -0
- package/dist/cjs/src/utils/swapMath.js +78 -0
- package/dist/cjs/src/utils/swapMath.js.map +1 -0
- package/dist/cjs/src/utils/tickLibrary.d.ts +14 -0
- package/dist/cjs/src/utils/tickLibrary.js +51 -0
- package/dist/cjs/src/utils/tickLibrary.js.map +1 -0
- package/dist/cjs/src/utils/tickList.d.ts +23 -0
- package/dist/cjs/src/utils/tickList.js +108 -0
- package/dist/cjs/src/utils/tickList.js.map +1 -0
- package/dist/cjs/src/utils/tickMath.d.ts +34 -0
- package/dist/cjs/src/utils/tickMath.js +125 -0
- package/dist/cjs/src/utils/tickMath.js.map +1 -0
- package/dist/cjs/src/utils/v3swap.d.ts +8 -0
- package/dist/cjs/src/utils/v3swap.js +85 -0
- package/dist/cjs/src/utils/v3swap.js.map +1 -0
- package/dist/esm/src/constants.d.ts +23 -0
- package/dist/esm/src/constants.js +40 -0
- package/dist/esm/src/constants.js.map +1 -0
- package/dist/esm/src/entities/index.d.ts +7 -0
- package/dist/esm/src/entities/index.js +8 -0
- package/dist/esm/src/entities/index.js.map +1 -0
- package/dist/esm/src/entities/pool.d.ts +81 -0
- package/dist/esm/src/entities/pool.js +137 -0
- package/dist/esm/src/entities/pool.js.map +1 -0
- package/dist/esm/src/entities/position.d.ts +131 -0
- package/dist/esm/src/entities/position.js +243 -0
- package/dist/esm/src/entities/position.js.map +1 -0
- package/dist/esm/src/entities/route.d.ts +26 -0
- package/dist/esm/src/entities/route.js +70 -0
- package/dist/esm/src/entities/route.js.map +1 -0
- package/dist/esm/src/entities/tick.d.ts +13 -0
- package/dist/esm/src/entities/tick.js +12 -0
- package/dist/esm/src/entities/tick.js.map +1 -0
- package/dist/esm/src/entities/tickDataProvider.d.ts +31 -0
- package/dist/esm/src/entities/tickDataProvider.js +14 -0
- package/dist/esm/src/entities/tickDataProvider.js.map +1 -0
- package/dist/esm/src/entities/tickListDataProvider.d.ts +15 -0
- package/dist/esm/src/entities/tickListDataProvider.js +19 -0
- package/dist/esm/src/entities/tickListDataProvider.js.map +1 -0
- package/dist/esm/src/entities/trade.d.ts +220 -0
- package/dist/esm/src/entities/trade.js +434 -0
- package/dist/esm/src/entities/trade.js.map +1 -0
- package/dist/esm/src/index.d.ts +10 -0
- package/dist/esm/src/index.js +11 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/internalConstants.d.ts +6 -0
- package/dist/esm/src/internalConstants.js +9 -0
- package/dist/esm/src/internalConstants.js.map +1 -0
- package/dist/esm/src/multicall.d.ts +10 -0
- package/dist/esm/src/multicall.js +19 -0
- package/dist/esm/src/multicall.js.map +1 -0
- package/dist/esm/src/nonfungiblePositionManager.d.ts +159 -0
- package/dist/esm/src/nonfungiblePositionManager.js +245 -0
- package/dist/esm/src/nonfungiblePositionManager.js.map +1 -0
- package/dist/esm/src/payments.d.ts +24 -0
- package/dist/esm/src/payments.js +51 -0
- package/dist/esm/src/payments.js.map +1 -0
- package/dist/esm/src/quoter.d.ts +37 -0
- package/dist/esm/src/quoter.js +64 -0
- package/dist/esm/src/quoter.js.map +1 -0
- package/dist/esm/src/selfPermit.d.ts +25 -0
- package/dist/esm/src/selfPermit.js +33 -0
- package/dist/esm/src/selfPermit.js.map +1 -0
- package/dist/esm/src/staker.d.ts +101 -0
- package/dist/esm/src/staker.js +124 -0
- package/dist/esm/src/staker.js.map +1 -0
- package/dist/esm/src/swapRouter.d.ts +51 -0
- package/dist/esm/src/swapRouter.js +140 -0
- package/dist/esm/src/swapRouter.js.map +1 -0
- package/dist/esm/src/utils/calldata.d.ts +20 -0
- package/dist/esm/src/utils/calldata.js +15 -0
- package/dist/esm/src/utils/calldata.js.map +1 -0
- package/dist/esm/src/utils/computePoolAddress.d.ts +20 -0
- package/dist/esm/src/utils/computePoolAddress.js +29 -0
- package/dist/esm/src/utils/computePoolAddress.js.map +1 -0
- package/dist/esm/src/utils/encodeRouteToPath.d.ts +8 -0
- package/dist/esm/src/utils/encodeRouteToPath.js +28 -0
- package/dist/esm/src/utils/encodeRouteToPath.js.map +1 -0
- package/dist/esm/src/utils/encodeSqrtRatioX96.d.ts +9 -0
- package/dist/esm/src/utils/encodeSqrtRatioX96.js +15 -0
- package/dist/esm/src/utils/encodeSqrtRatioX96.js.map +1 -0
- package/dist/esm/src/utils/fullMath.d.ts +8 -0
- package/dist/esm/src/utils/fullMath.js +16 -0
- package/dist/esm/src/utils/fullMath.js.map +1 -0
- package/dist/esm/src/utils/index.d.ts +18 -0
- package/dist/esm/src/utils/index.js +19 -0
- package/dist/esm/src/utils/index.js.map +1 -0
- package/dist/esm/src/utils/isSorted.d.ts +7 -0
- package/dist/esm/src/utils/isSorted.js +15 -0
- package/dist/esm/src/utils/isSorted.js.map +1 -0
- package/dist/esm/src/utils/liquidityMath.d.ts +8 -0
- package/dist/esm/src/utils/liquidityMath.js +17 -0
- package/dist/esm/src/utils/liquidityMath.js.map +1 -0
- package/dist/esm/src/utils/maxLiquidityForAmounts.d.ts +14 -0
- package/dist/esm/src/utils/maxLiquidityForAmounts.js +82 -0
- package/dist/esm/src/utils/maxLiquidityForAmounts.js.map +1 -0
- package/dist/esm/src/utils/mostSignificantBit.d.ts +2 -0
- package/dist/esm/src/utils/mostSignificantBit.js +22 -0
- package/dist/esm/src/utils/mostSignificantBit.js.map +1 -0
- package/dist/esm/src/utils/nearestUsableTick.d.ts +6 -0
- package/dist/esm/src/utils/nearestUsableTick.js +20 -0
- package/dist/esm/src/utils/nearestUsableTick.js.map +1 -0
- package/dist/esm/src/utils/position.d.ts +8 -0
- package/dist/esm/src/utils/position.js +16 -0
- package/dist/esm/src/utils/position.js.map +1 -0
- package/dist/esm/src/utils/priceTickConversions.d.ts +15 -0
- package/dist/esm/src/utils/priceTickConversions.js +44 -0
- package/dist/esm/src/utils/priceTickConversions.js.map +1 -0
- package/dist/esm/src/utils/sqrtPriceMath.d.ts +13 -0
- package/dist/esm/src/utils/sqrtPriceMath.js +90 -0
- package/dist/esm/src/utils/sqrtPriceMath.js.map +1 -0
- package/dist/esm/src/utils/swapMath.d.ts +9 -0
- package/dist/esm/src/utils/swapMath.js +73 -0
- package/dist/esm/src/utils/swapMath.js.map +1 -0
- package/dist/esm/src/utils/tickLibrary.d.ts +14 -0
- package/dist/esm/src/utils/tickLibrary.js +45 -0
- package/dist/esm/src/utils/tickLibrary.js.map +1 -0
- package/dist/esm/src/utils/tickList.d.ts +23 -0
- package/dist/esm/src/utils/tickList.js +103 -0
- package/dist/esm/src/utils/tickList.js.map +1 -0
- package/dist/esm/src/utils/tickMath.d.ts +34 -0
- package/dist/esm/src/utils/tickMath.js +120 -0
- package/dist/esm/src/utils/tickMath.js.map +1 -0
- package/dist/esm/src/utils/v3swap.d.ts +8 -0
- package/dist/esm/src/utils/v3swap.js +80 -0
- package/dist/esm/src/utils/v3swap.js.map +1 -0
- package/dist/types/src/constants.d.ts +23 -0
- package/dist/types/src/entities/index.d.ts +7 -0
- package/dist/types/src/entities/pool.d.ts +81 -0
- package/dist/types/src/entities/position.d.ts +131 -0
- package/dist/types/src/entities/route.d.ts +26 -0
- package/dist/types/src/entities/tick.d.ts +13 -0
- package/dist/types/src/entities/tickDataProvider.d.ts +31 -0
- package/dist/types/src/entities/tickListDataProvider.d.ts +15 -0
- package/dist/types/src/entities/trade.d.ts +220 -0
- package/dist/types/src/index.d.ts +10 -0
- package/dist/types/src/internalConstants.d.ts +6 -0
- package/dist/types/src/multicall.d.ts +10 -0
- package/dist/types/src/nonfungiblePositionManager.d.ts +159 -0
- package/dist/types/src/payments.d.ts +24 -0
- package/dist/types/src/quoter.d.ts +37 -0
- package/dist/types/src/selfPermit.d.ts +25 -0
- package/dist/types/src/staker.d.ts +101 -0
- package/dist/types/src/swapRouter.d.ts +51 -0
- package/dist/types/src/utils/calldata.d.ts +20 -0
- package/dist/types/src/utils/computePoolAddress.d.ts +20 -0
- package/dist/types/src/utils/encodeRouteToPath.d.ts +8 -0
- package/dist/types/src/utils/encodeSqrtRatioX96.d.ts +9 -0
- package/dist/types/src/utils/fullMath.d.ts +8 -0
- package/dist/types/src/utils/index.d.ts +18 -0
- package/dist/types/src/utils/isSorted.d.ts +7 -0
- package/dist/types/src/utils/liquidityMath.d.ts +8 -0
- package/dist/types/src/utils/maxLiquidityForAmounts.d.ts +14 -0
- package/dist/types/src/utils/mostSignificantBit.d.ts +2 -0
- package/dist/types/src/utils/nearestUsableTick.d.ts +6 -0
- package/dist/types/src/utils/position.d.ts +8 -0
- package/dist/types/src/utils/priceTickConversions.d.ts +15 -0
- package/dist/types/src/utils/sqrtPriceMath.d.ts +13 -0
- package/dist/types/src/utils/swapMath.d.ts +9 -0
- package/dist/types/src/utils/tickLibrary.d.ts +14 -0
- package/dist/types/src/utils/tickList.d.ts +23 -0
- package/dist/types/src/utils/tickMath.d.ts +34 -0
- package/dist/types/src/utils/v3swap.d.ts +8 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Uniswap Labs
|
|
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,13 @@
|
|
|
1
|
+
# Alpha software
|
|
2
|
+
|
|
3
|
+
The latest version of the SDK is used in production in the Uniswap Interface,
|
|
4
|
+
but it is considered Alpha software and may contain bugs or change significantly between patch versions.
|
|
5
|
+
If you have questions about how to use the SDK, please reach out in the `#dev-chat` channel of the Discord.
|
|
6
|
+
Pull requests welcome!
|
|
7
|
+
|
|
8
|
+
# Uniswap V3 SDK
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/@uniswap/v3-sdk/v/latest)
|
|
11
|
+
[](https://bundlephobia.com/result?p=@uniswap/v3-sdk@latest)
|
|
12
|
+
|
|
13
|
+
In-depth documentation on this SDK is available at [uniswap.org](https://docs.uniswap.org/).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChainId } from '@centurion_project/sdk-core';
|
|
2
|
+
export declare const FACTORY_ADDRESS = "0x1F98431c8aD98523631AE4a59f267346ea31F984";
|
|
3
|
+
export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
|
|
4
|
+
export declare const POOL_INIT_CODE_HASH = "0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54";
|
|
5
|
+
export declare function poolInitCodeHash(chainId?: ChainId): string;
|
|
6
|
+
/**
|
|
7
|
+
* The default factory enabled fee amounts, denominated in hundredths of bips.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum FeeAmount {
|
|
10
|
+
LOWEST = 100,
|
|
11
|
+
LOW_200 = 200,
|
|
12
|
+
LOW_300 = 300,
|
|
13
|
+
LOW_400 = 400,
|
|
14
|
+
LOW = 500,
|
|
15
|
+
MEDIUM = 3000,
|
|
16
|
+
HIGH = 10000
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The default factory tick spacings by fee amount.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TICK_SPACINGS: {
|
|
22
|
+
[amount in FeeAmount]: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TICK_SPACINGS = exports.FeeAmount = exports.poolInitCodeHash = exports.POOL_INIT_CODE_HASH = exports.ADDRESS_ZERO = exports.FACTORY_ADDRESS = void 0;
|
|
4
|
+
const sdk_core_1 = require("@centurion_project/sdk-core");
|
|
5
|
+
exports.FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984';
|
|
6
|
+
exports.ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
|
|
7
|
+
// @deprecated please use poolInitCodeHash(chainId: ChainId)
|
|
8
|
+
exports.POOL_INIT_CODE_HASH = '0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54';
|
|
9
|
+
function poolInitCodeHash(chainId) {
|
|
10
|
+
switch (chainId) {
|
|
11
|
+
case sdk_core_1.ChainId.ZKSYNC:
|
|
12
|
+
return '0x010013f177ea1fcbc4520f9a3ca7cd2d1d77959e05aa66484027cb38e712aeed';
|
|
13
|
+
default:
|
|
14
|
+
return exports.POOL_INIT_CODE_HASH;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.poolInitCodeHash = poolInitCodeHash;
|
|
18
|
+
/**
|
|
19
|
+
* The default factory enabled fee amounts, denominated in hundredths of bips.
|
|
20
|
+
*/
|
|
21
|
+
var FeeAmount;
|
|
22
|
+
(function (FeeAmount) {
|
|
23
|
+
FeeAmount[FeeAmount["LOWEST"] = 100] = "LOWEST";
|
|
24
|
+
FeeAmount[FeeAmount["LOW_200"] = 200] = "LOW_200";
|
|
25
|
+
FeeAmount[FeeAmount["LOW_300"] = 300] = "LOW_300";
|
|
26
|
+
FeeAmount[FeeAmount["LOW_400"] = 400] = "LOW_400";
|
|
27
|
+
FeeAmount[FeeAmount["LOW"] = 500] = "LOW";
|
|
28
|
+
FeeAmount[FeeAmount["MEDIUM"] = 3000] = "MEDIUM";
|
|
29
|
+
FeeAmount[FeeAmount["HIGH"] = 10000] = "HIGH";
|
|
30
|
+
})(FeeAmount = exports.FeeAmount || (exports.FeeAmount = {}));
|
|
31
|
+
/**
|
|
32
|
+
* The default factory tick spacings by fee amount.
|
|
33
|
+
*/
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
exports.TICK_SPACINGS = {
|
|
36
|
+
[FeeAmount.LOWEST]: 1,
|
|
37
|
+
[FeeAmount.LOW_200]: 4,
|
|
38
|
+
[FeeAmount.LOW_300]: 6,
|
|
39
|
+
[FeeAmount.LOW_400]: 8,
|
|
40
|
+
[FeeAmount.LOW]: 10,
|
|
41
|
+
[FeeAmount.MEDIUM]: 60,
|
|
42
|
+
[FeeAmount.HIGH]: 200,
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAExC,QAAA,eAAe,GAAG,4CAA4C,CAAA;AAE9D,QAAA,YAAY,GAAG,4CAA4C,CAAA;AAExE,4DAA4D;AAC/C,QAAA,mBAAmB,GAAG,oEAAoE,CAAA;AAEvG,SAAgB,gBAAgB,CAAC,OAAiB;IAChD,QAAQ,OAAO,EAAE;QACf,KAAK,kBAAO,CAAC,MAAM;YACjB,OAAO,oEAAoE,CAAA;QAC7E;YACE,OAAO,2BAAmB,CAAA;KAC7B;AACH,CAAC;AAPD,4CAOC;AAED;;GAEG;AACH,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,+CAAY,CAAA;IACZ,iDAAa,CAAA;IACb,iDAAa,CAAA;IACb,iDAAa,CAAA;IACb,yCAAS,CAAA;IACT,gDAAa,CAAA;IACb,6CAAY,CAAA;AACd,CAAC,EARW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAQpB;AAED;;GAEG;AACH,6DAA6D;AAChD,QAAA,aAAa,GAAsC;IAC9D,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IACrB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;IACtB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;IACtB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;IACtB,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE;IACnB,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE;IACtB,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG;CACtB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./pool"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./position"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./route"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./tick"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./trade"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./tickDataProvider"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./tickListDataProvider"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/entities/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,qDAA0B;AAC1B,kDAAuB;AACvB,iDAAsB;AACtB,kDAAuB;AACvB,6DAAkC;AAClC,iEAAsC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { BigintIsh, CurrencyAmount, Price, Token } from '@centurion_project/sdk-core';
|
|
2
|
+
import JSBI from 'jsbi';
|
|
3
|
+
import { FeeAmount } from '../constants';
|
|
4
|
+
import { Tick, TickConstructorArgs } from './tick';
|
|
5
|
+
import { TickDataProvider } from './tickDataProvider';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a V3 pool
|
|
8
|
+
*/
|
|
9
|
+
export declare class Pool {
|
|
10
|
+
readonly token0: Token;
|
|
11
|
+
readonly token1: Token;
|
|
12
|
+
readonly fee: FeeAmount;
|
|
13
|
+
readonly sqrtRatioX96: JSBI;
|
|
14
|
+
readonly liquidity: JSBI;
|
|
15
|
+
readonly tickCurrent: number;
|
|
16
|
+
readonly tickDataProvider: TickDataProvider;
|
|
17
|
+
private _token0Price?;
|
|
18
|
+
private _token1Price?;
|
|
19
|
+
static getAddress(tokenA: Token, tokenB: Token, fee: FeeAmount, initCodeHashManualOverride?: string, factoryAddressOverride?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Construct a pool
|
|
22
|
+
* @param tokenA One of the tokens in the pool
|
|
23
|
+
* @param tokenB The other token in the pool
|
|
24
|
+
* @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
|
|
25
|
+
* @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0
|
|
26
|
+
* @param liquidity The current value of in range liquidity
|
|
27
|
+
* @param tickCurrent The current tick of the pool
|
|
28
|
+
* @param ticks The current state of the pool ticks or a data provider that can return tick data
|
|
29
|
+
*/
|
|
30
|
+
constructor(tokenA: Token, tokenB: Token, fee: FeeAmount, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number, ticks?: TickDataProvider | (Tick | TickConstructorArgs)[]);
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the token is either token0 or token1
|
|
33
|
+
* @param token The token to check
|
|
34
|
+
* @returns True if token is either token0 or token
|
|
35
|
+
*/
|
|
36
|
+
involvesToken(token: Token): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
|
|
39
|
+
*/
|
|
40
|
+
get token0Price(): Price<Token, Token>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
|
|
43
|
+
*/
|
|
44
|
+
get token1Price(): Price<Token, Token>;
|
|
45
|
+
/**
|
|
46
|
+
* Return the price of the given token in terms of the other token in the pool.
|
|
47
|
+
* @param token The token to return price of
|
|
48
|
+
* @returns The price of the given token, in terms of the other.
|
|
49
|
+
*/
|
|
50
|
+
priceOf(token: Token): Price<Token, Token>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the chain ID of the tokens in the pool.
|
|
53
|
+
*/
|
|
54
|
+
get chainId(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
|
|
57
|
+
* @param inputAmount The input amount for which to quote the output amount
|
|
58
|
+
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit
|
|
59
|
+
* @returns The output amount and the pool with updated state
|
|
60
|
+
*/
|
|
61
|
+
getOutputAmount(inputAmount: CurrencyAmount<Token>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Token>, Pool]>;
|
|
62
|
+
/**
|
|
63
|
+
* Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
|
|
64
|
+
* @param outputAmount the output amount for which to quote the input amount
|
|
65
|
+
* @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
|
|
66
|
+
* @returns The input amount and the pool with updated state
|
|
67
|
+
*/
|
|
68
|
+
getInputAmount(outputAmount: CurrencyAmount<Token>, sqrtPriceLimitX96?: JSBI): Promise<[CurrencyAmount<Token>, Pool]>;
|
|
69
|
+
/**
|
|
70
|
+
* Executes a swap
|
|
71
|
+
* @param zeroForOne Whether the amount in is token0 or token1
|
|
72
|
+
* @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
|
|
73
|
+
* @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
|
|
74
|
+
* @returns amountCalculated
|
|
75
|
+
* @returns sqrtRatioX96
|
|
76
|
+
* @returns liquidity
|
|
77
|
+
* @returns tickCurrent
|
|
78
|
+
*/
|
|
79
|
+
private swap;
|
|
80
|
+
get tickSpacing(): number;
|
|
81
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pool = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sdk_core_1 = require("@centurion_project/sdk-core");
|
|
6
|
+
const jsbi_1 = tslib_1.__importDefault(require("jsbi"));
|
|
7
|
+
const tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const internalConstants_1 = require("../internalConstants");
|
|
10
|
+
const computePoolAddress_1 = require("../utils/computePoolAddress");
|
|
11
|
+
const v3swap_1 = require("../utils/v3swap");
|
|
12
|
+
const tickMath_1 = require("../utils/tickMath");
|
|
13
|
+
const tickDataProvider_1 = require("./tickDataProvider");
|
|
14
|
+
const tickListDataProvider_1 = require("./tickListDataProvider");
|
|
15
|
+
/**
|
|
16
|
+
* By default, pools will not allow operations that require ticks.
|
|
17
|
+
*/
|
|
18
|
+
const NO_TICK_DATA_PROVIDER_DEFAULT = new tickDataProvider_1.NoTickDataProvider();
|
|
19
|
+
/**
|
|
20
|
+
* Represents a V3 pool
|
|
21
|
+
*/
|
|
22
|
+
class Pool {
|
|
23
|
+
static getAddress(tokenA, tokenB, fee, initCodeHashManualOverride, factoryAddressOverride) {
|
|
24
|
+
return (0, computePoolAddress_1.computePoolAddress)({
|
|
25
|
+
factoryAddress: factoryAddressOverride !== null && factoryAddressOverride !== void 0 ? factoryAddressOverride : constants_1.FACTORY_ADDRESS,
|
|
26
|
+
fee,
|
|
27
|
+
tokenA,
|
|
28
|
+
tokenB,
|
|
29
|
+
initCodeHashManualOverride,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Construct a pool
|
|
34
|
+
* @param tokenA One of the tokens in the pool
|
|
35
|
+
* @param tokenB The other token in the pool
|
|
36
|
+
* @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
|
|
37
|
+
* @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0
|
|
38
|
+
* @param liquidity The current value of in range liquidity
|
|
39
|
+
* @param tickCurrent The current tick of the pool
|
|
40
|
+
* @param ticks The current state of the pool ticks or a data provider that can return tick data
|
|
41
|
+
*/
|
|
42
|
+
constructor(tokenA, tokenB, fee, sqrtRatioX96, liquidity, tickCurrent, ticks = NO_TICK_DATA_PROVIDER_DEFAULT) {
|
|
43
|
+
(0, tiny_invariant_1.default)(Number.isInteger(fee) && fee < 1000000, 'FEE');
|
|
44
|
+
const tickCurrentSqrtRatioX96 = tickMath_1.TickMath.getSqrtRatioAtTick(tickCurrent);
|
|
45
|
+
const nextTickSqrtRatioX96 = tickMath_1.TickMath.getSqrtRatioAtTick(tickCurrent + 1);
|
|
46
|
+
(0, tiny_invariant_1.default)(jsbi_1.default.greaterThanOrEqual(jsbi_1.default.BigInt(sqrtRatioX96), tickCurrentSqrtRatioX96) &&
|
|
47
|
+
jsbi_1.default.lessThanOrEqual(jsbi_1.default.BigInt(sqrtRatioX96), nextTickSqrtRatioX96), 'PRICE_BOUNDS');
|
|
48
|
+
[this.token0, this.token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA];
|
|
49
|
+
this.fee = fee;
|
|
50
|
+
this.sqrtRatioX96 = jsbi_1.default.BigInt(sqrtRatioX96);
|
|
51
|
+
this.liquidity = jsbi_1.default.BigInt(liquidity);
|
|
52
|
+
this.tickCurrent = tickCurrent;
|
|
53
|
+
this.tickDataProvider = Array.isArray(ticks) ? new tickListDataProvider_1.TickListDataProvider(ticks, constants_1.TICK_SPACINGS[fee]) : ticks;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns true if the token is either token0 or token1
|
|
57
|
+
* @param token The token to check
|
|
58
|
+
* @returns True if token is either token0 or token
|
|
59
|
+
*/
|
|
60
|
+
involvesToken(token) {
|
|
61
|
+
return token.equals(this.token0) || token.equals(this.token1);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
|
|
65
|
+
*/
|
|
66
|
+
get token0Price() {
|
|
67
|
+
var _a;
|
|
68
|
+
return ((_a = this._token0Price) !== null && _a !== void 0 ? _a : (this._token0Price = new sdk_core_1.Price(this.token0, this.token1, internalConstants_1.Q192, jsbi_1.default.multiply(this.sqrtRatioX96, this.sqrtRatioX96))));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
|
|
72
|
+
*/
|
|
73
|
+
get token1Price() {
|
|
74
|
+
var _a;
|
|
75
|
+
return ((_a = this._token1Price) !== null && _a !== void 0 ? _a : (this._token1Price = new sdk_core_1.Price(this.token1, this.token0, jsbi_1.default.multiply(this.sqrtRatioX96, this.sqrtRatioX96), internalConstants_1.Q192)));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Return the price of the given token in terms of the other token in the pool.
|
|
79
|
+
* @param token The token to return price of
|
|
80
|
+
* @returns The price of the given token, in terms of the other.
|
|
81
|
+
*/
|
|
82
|
+
priceOf(token) {
|
|
83
|
+
(0, tiny_invariant_1.default)(this.involvesToken(token), 'TOKEN');
|
|
84
|
+
return token.equals(this.token0) ? this.token0Price : this.token1Price;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns the chain ID of the tokens in the pool.
|
|
88
|
+
*/
|
|
89
|
+
get chainId() {
|
|
90
|
+
return this.token0.chainId;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
|
|
94
|
+
* @param inputAmount The input amount for which to quote the output amount
|
|
95
|
+
* @param sqrtPriceLimitX96 The Q64.96 sqrt price limit
|
|
96
|
+
* @returns The output amount and the pool with updated state
|
|
97
|
+
*/
|
|
98
|
+
async getOutputAmount(inputAmount, sqrtPriceLimitX96) {
|
|
99
|
+
(0, tiny_invariant_1.default)(this.involvesToken(inputAmount.currency), 'TOKEN');
|
|
100
|
+
const zeroForOne = inputAmount.currency.equals(this.token0);
|
|
101
|
+
const { amountCalculated: outputAmount, sqrtRatioX96, liquidity, tickCurrent, } = await this.swap(zeroForOne, inputAmount.quotient, sqrtPriceLimitX96);
|
|
102
|
+
const outputToken = zeroForOne ? this.token1 : this.token0;
|
|
103
|
+
return [
|
|
104
|
+
sdk_core_1.CurrencyAmount.fromRawAmount(outputToken, jsbi_1.default.multiply(outputAmount, internalConstants_1.NEGATIVE_ONE)),
|
|
105
|
+
new Pool(this.token0, this.token1, this.fee, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider),
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
|
|
110
|
+
* @param outputAmount the output amount for which to quote the input amount
|
|
111
|
+
* @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
|
|
112
|
+
* @returns The input amount and the pool with updated state
|
|
113
|
+
*/
|
|
114
|
+
async getInputAmount(outputAmount, sqrtPriceLimitX96) {
|
|
115
|
+
(0, tiny_invariant_1.default)(outputAmount.currency.isToken && this.involvesToken(outputAmount.currency), 'TOKEN');
|
|
116
|
+
const zeroForOne = outputAmount.currency.equals(this.token1);
|
|
117
|
+
const { amountCalculated: inputAmount, sqrtRatioX96, liquidity, tickCurrent, } = await this.swap(zeroForOne, jsbi_1.default.multiply(outputAmount.quotient, internalConstants_1.NEGATIVE_ONE), sqrtPriceLimitX96);
|
|
118
|
+
const inputToken = zeroForOne ? this.token0 : this.token1;
|
|
119
|
+
return [
|
|
120
|
+
sdk_core_1.CurrencyAmount.fromRawAmount(inputToken, inputAmount),
|
|
121
|
+
new Pool(this.token0, this.token1, this.fee, sqrtRatioX96, liquidity, tickCurrent, this.tickDataProvider),
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Executes a swap
|
|
126
|
+
* @param zeroForOne Whether the amount in is token0 or token1
|
|
127
|
+
* @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
|
|
128
|
+
* @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
|
|
129
|
+
* @returns amountCalculated
|
|
130
|
+
* @returns sqrtRatioX96
|
|
131
|
+
* @returns liquidity
|
|
132
|
+
* @returns tickCurrent
|
|
133
|
+
*/
|
|
134
|
+
async swap(zeroForOne, amountSpecified, sqrtPriceLimitX96) {
|
|
135
|
+
return (0, v3swap_1.v3Swap)(jsbi_1.default.BigInt(this.fee), this.sqrtRatioX96, this.tickCurrent, this.liquidity, this.tickSpacing, this.tickDataProvider, zeroForOne, amountSpecified, sqrtPriceLimitX96);
|
|
136
|
+
}
|
|
137
|
+
get tickSpacing() {
|
|
138
|
+
return constants_1.TICK_SPACINGS[this.fee];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.Pool = Pool;
|
|
142
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../../src/entities/pool.ts"],"names":[],"mappings":";;;;AAAA,0DAAqF;AACrF,wDAAuB;AACvB,4EAAsC;AACtC,4CAAwE;AACxE,4DAAyD;AACzD,oEAAgE;AAChE,4CAAwC;AACxC,gDAA4C;AAE5C,yDAAyE;AACzE,iEAA6D;AAE7D;;GAEG;AACH,MAAM,6BAA6B,GAAG,IAAI,qCAAkB,EAAE,CAAA;AAE9D;;GAEG;AACH,MAAa,IAAI;IAYR,MAAM,CAAC,UAAU,CACtB,MAAa,EACb,MAA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AAM,CAAC,CAAA;QAE5D,MAAM,EACJ,gBAAgB,EAAE,WAAW,EAC7B,YAAY,EACZ,SAAS,EACT,WAAW,GACZ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,gCAAY,CAAC,EAAE,iBAAiB,CAAC,CAAA;QACtG,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;QACzD,OAAO;YACL,yBAAc,CAAC,aAAa,CAAC,UAAU,EAAE,WAAW,CAAC;YACrD,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC;SAC1G,CAAA;IACH,CAAC;IAED;;;;;;;;;OASG;IACK,KAAK,CAAC,IAAI,CAChB,UAAmB,EACnB,eAAqB,EACrB,iBAAwB;QAExB,OAAO,IAAA,eAAM,EACX,cAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EACrB,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,gBAAgB,EACrB,UAAU,EACV,eAAe,EACf,iBAAiB,CAClB,CAAA;IACH,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,yBAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;CACF;AA9MD,oBA8MC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { BigintIsh, Percent, Price, CurrencyAmount, Token } from '@centurion_project/sdk-core';
|
|
2
|
+
import JSBI from 'jsbi';
|
|
3
|
+
import { Pool } from './pool';
|
|
4
|
+
interface PositionConstructorArgs {
|
|
5
|
+
pool: Pool;
|
|
6
|
+
tickLower: number;
|
|
7
|
+
tickUpper: number;
|
|
8
|
+
liquidity: BigintIsh;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Represents a position on a Uniswap V3 Pool
|
|
12
|
+
*/
|
|
13
|
+
export declare class Position {
|
|
14
|
+
readonly pool: Pool;
|
|
15
|
+
readonly tickLower: number;
|
|
16
|
+
readonly tickUpper: number;
|
|
17
|
+
readonly liquidity: JSBI;
|
|
18
|
+
private _token0Amount;
|
|
19
|
+
private _token1Amount;
|
|
20
|
+
private _mintAmounts;
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a position for a given pool with the given liquidity
|
|
23
|
+
* @param pool For which pool the liquidity is assigned
|
|
24
|
+
* @param liquidity The amount of liquidity that is in the position
|
|
25
|
+
* @param tickLower The lower tick of the position
|
|
26
|
+
* @param tickUpper The upper tick of the position
|
|
27
|
+
*/
|
|
28
|
+
constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs);
|
|
29
|
+
/**
|
|
30
|
+
* Returns the price of token0 at the lower tick
|
|
31
|
+
*/
|
|
32
|
+
get token0PriceLower(): Price<Token, Token>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the price of token0 at the upper tick
|
|
35
|
+
*/
|
|
36
|
+
get token0PriceUpper(): Price<Token, Token>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
|
|
39
|
+
*/
|
|
40
|
+
get amount0(): CurrencyAmount<Token>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
|
|
43
|
+
*/
|
|
44
|
+
get amount1(): CurrencyAmount<Token>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
|
|
47
|
+
* @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
|
|
48
|
+
* @returns The sqrt ratios after slippage
|
|
49
|
+
*/
|
|
50
|
+
private ratiosAfterSlippage;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position
|
|
53
|
+
* with the given slippage tolerance
|
|
54
|
+
* @param slippageTolerance Tolerance of unfavorable slippage from the current price
|
|
55
|
+
* @returns The amounts, with slippage
|
|
56
|
+
*/
|
|
57
|
+
mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
|
|
58
|
+
amount0: JSBI;
|
|
59
|
+
amount1: JSBI;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
|
|
63
|
+
* position with the given slippage tolerance
|
|
64
|
+
* @param slippageTolerance tolerance of unfavorable slippage from the current price
|
|
65
|
+
* @returns The amounts, with slippage
|
|
66
|
+
*/
|
|
67
|
+
burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{
|
|
68
|
+
amount0: JSBI;
|
|
69
|
+
amount1: JSBI;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
|
|
73
|
+
* the current price for the pool
|
|
74
|
+
*/
|
|
75
|
+
get mintAmounts(): Readonly<{
|
|
76
|
+
amount0: JSBI;
|
|
77
|
+
amount1: JSBI;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Computes the maximum amount of liquidity received for a given amount of token0, token1,
|
|
81
|
+
* and the prices at the tick boundaries.
|
|
82
|
+
* @param pool The pool for which the position should be created
|
|
83
|
+
* @param tickLower The lower tick of the position
|
|
84
|
+
* @param tickUpper The upper tick of the position
|
|
85
|
+
* @param amount0 token0 amount
|
|
86
|
+
* @param amount1 token1 amount
|
|
87
|
+
* @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
|
|
88
|
+
* not what core can theoretically support
|
|
89
|
+
* @returns The amount of liquidity for the position
|
|
90
|
+
*/
|
|
91
|
+
static fromAmounts({ pool, tickLower, tickUpper, amount0, amount1, useFullPrecision, }: {
|
|
92
|
+
pool: Pool;
|
|
93
|
+
tickLower: number;
|
|
94
|
+
tickUpper: number;
|
|
95
|
+
amount0: BigintIsh;
|
|
96
|
+
amount1: BigintIsh;
|
|
97
|
+
useFullPrecision: boolean;
|
|
98
|
+
}): Position;
|
|
99
|
+
/**
|
|
100
|
+
* Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
|
|
101
|
+
* @param pool The pool for which the position is created
|
|
102
|
+
* @param tickLower The lower tick
|
|
103
|
+
* @param tickUpper The upper tick
|
|
104
|
+
* @param amount0 The desired amount of token0
|
|
105
|
+
* @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
|
|
106
|
+
* not what core can theoretically support
|
|
107
|
+
* @returns The position
|
|
108
|
+
*/
|
|
109
|
+
static fromAmount0({ pool, tickLower, tickUpper, amount0, useFullPrecision, }: {
|
|
110
|
+
pool: Pool;
|
|
111
|
+
tickLower: number;
|
|
112
|
+
tickUpper: number;
|
|
113
|
+
amount0: BigintIsh;
|
|
114
|
+
useFullPrecision: boolean;
|
|
115
|
+
}): Position;
|
|
116
|
+
/**
|
|
117
|
+
* Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
|
|
118
|
+
* @param pool The pool for which the position is created
|
|
119
|
+
* @param tickLower The lower tick
|
|
120
|
+
* @param tickUpper The upper tick
|
|
121
|
+
* @param amount1 The desired amount of token1
|
|
122
|
+
* @returns The position
|
|
123
|
+
*/
|
|
124
|
+
static fromAmount1({ pool, tickLower, tickUpper, amount1, }: {
|
|
125
|
+
pool: Pool;
|
|
126
|
+
tickLower: number;
|
|
127
|
+
tickUpper: number;
|
|
128
|
+
amount1: BigintIsh;
|
|
129
|
+
}): Position;
|
|
130
|
+
}
|
|
131
|
+
export {};
|