From b2ea9b895506212e52816dce5f8c010e39671563 Mon Sep 17 00:00:00 2001 From: Koray Koska <11356621+koraykoska@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:23:52 +0100 Subject: [PATCH 1/2] fix: js-only project support --- jest.config.js => jest.config.cjs | 2 ++ package.json | 5 ++-- src/entities/index.ts | 14 +++++------ src/entities/pool.ts | 22 ++++++++--------- src/entities/position.ts | 20 ++++++++-------- src/entities/route.ts | 2 +- src/entities/rpcTickDataProvider.ts | 10 ++++---- src/entities/tick.ts | 4 ++-- src/entities/tickListDataProvider.ts | 6 ++--- src/entities/trade.ts | 6 ++--- src/index.ts | 20 ++++++++-------- src/nonfungiblePositionManager.ts | 16 ++++++------- src/payments.ts | 2 +- src/quoter.ts | 6 ++--- src/selfPermit.ts | 2 +- src/staker.ts | 6 ++--- src/swapRouter.ts | 22 ++++++++--------- src/utils/approveTokenTransfer.ts | 2 +- src/utils/calldata.ts | 2 +- src/utils/computePoolAddress.ts | 2 +- src/utils/encodeRouteToPath.ts | 4 ++-- src/utils/encodeSqrtRatioX96.ts | 2 +- src/utils/fetchTicksForRoute.ts | 4 ++-- src/utils/fullMath.ts | 2 +- src/utils/index.ts | 36 ++++++++++++++-------------- src/utils/liquidityMath.ts | 2 +- src/utils/maxLiquidityForAmounts.ts | 4 ++-- src/utils/mostSignificantBit.ts | 2 +- src/utils/nearestUsableTick.ts | 2 +- src/utils/position.ts | 4 ++-- src/utils/priceTickConversions.ts | 6 ++--- src/utils/rpcPool.ts | 2 +- src/utils/sqrtPriceMath.ts | 6 ++--- src/utils/swapMath.ts | 8 +++---- src/utils/tickLibrary.ts | 2 +- src/utils/tickList.ts | 4 ++-- src/utils/tickMath.ts | 4 ++-- src/v3migrator.ts | 4 ++-- yarn.lock | 32 ++++++++++++------------- 39 files changed, 152 insertions(+), 149 deletions(-) rename jest.config.js => jest.config.cjs (92%) diff --git a/jest.config.js b/jest.config.cjs similarity index 92% rename from jest.config.js rename to jest.config.cjs index 443c8d4f..6dd3edfc 100644 --- a/jest.config.js +++ b/jest.config.cjs @@ -26,6 +26,8 @@ module.exports = { 'src/(.*)': '/src/$1', // for esm modules in ts-jest '^(\\.{1,2}/.*)\\.js$': '$1', + // for .js imports + '(.+)\\.js$': ['$1.js', '$1'], }, extensionsToTreatAsEsm: ['.ts'], } diff --git a/package.json b/package.json index 252fd633..a0bacacc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "ethers": "^5.7.2", "@ethersproject/abi": "^5.0.12", "@ethersproject/solidity": "^5.0.9", - "@uniswap/sdk-core": "npm:@uniswapfoundation/sdk-core@^5.0.0", + "@uniswap/sdk-core": "npm:@uniswapfoundation/sdk-core@^5.0.1", "@uniswap/swap-router-contracts": "^1.2.1", "@uniswap/v3-periphery": "^1.1.1", "@uniswap/v3-staker": "1.0.2", @@ -50,5 +50,6 @@ "printWidth": 120, "semi": false, "singleQuote": true - } + }, + "type": "module" } diff --git a/src/entities/index.ts b/src/entities/index.ts index 031f0845..7a0dbcce 100644 --- a/src/entities/index.ts +++ b/src/entities/index.ts @@ -1,7 +1,7 @@ -export * from './pool' -export * from './position' -export * from './route' -export * from './tick' -export * from './trade' -export * from './tickDataProvider' -export * from './tickListDataProvider' +export * from './pool.js' +export * from './position.js' +export * from './route.js' +export * from './tick.js' +export * from './trade.js' +export * from './tickDataProvider.js' +export * from './tickListDataProvider.js' diff --git a/src/entities/pool.ts b/src/entities/pool.ts index 3a167524..73c2b273 100644 --- a/src/entities/pool.ts +++ b/src/entities/pool.ts @@ -1,18 +1,18 @@ import { BigintIsh, CurrencyAmount, Price, Token, V3_CORE_FACTORY_ADDRESSES } from '@uniswap/sdk-core' import JSBI from 'jsbi' import invariant from 'tiny-invariant' -import { FACTORY_ADDRESS, FeeAmount, TICK_SPACINGS } from '../constants' -import { Q192_BIGINT } from '../internalConstants' -import { computePoolAddress } from '../utils/computePoolAddress' -import { LiquidityMath } from '../utils/liquidityMath' -import { SwapMath } from '../utils/swapMath' -import { TickMath } from '../utils/tickMath' -import { Tick, TickConstructorArgs } from './tick' -import { NoTickDataProvider, TickDataProvider } from './tickDataProvider' -import { TickListDataProvider } from './tickListDataProvider' -import { bigIntFromBigintIsh } from '../utils/bigintIsh' +import { FACTORY_ADDRESS, FeeAmount, TICK_SPACINGS } from '../constants.js' +import { Q192_BIGINT } from '../internalConstants.js' +import { computePoolAddress } from '../utils/computePoolAddress.js' +import { LiquidityMath } from '../utils/liquidityMath.js' +import { SwapMath } from '../utils/swapMath.js' +import { TickMath } from '../utils/tickMath.js' +import { Tick, TickConstructorArgs } from './tick.js' +import { NoTickDataProvider, TickDataProvider } from './tickDataProvider.js' +import { TickListDataProvider } from './tickListDataProvider.js' +import { bigIntFromBigintIsh } from '../utils/bigintIsh.js' import { ethers } from 'ethers' -import { RPCTickDataProvider } from './rpcTickDataProvider' +import { RPCTickDataProvider } from './rpcTickDataProvider.js' import poolAbi from '@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json' import factoryAbi from '@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json' diff --git a/src/entities/position.ts b/src/entities/position.ts index 61fd7faa..1a130dd2 100644 --- a/src/entities/position.ts +++ b/src/entities/position.ts @@ -10,24 +10,24 @@ import { } from '@uniswap/sdk-core' import JSBI from 'jsbi' import invariant from 'tiny-invariant' -import { ZERO } from '../internalConstants' -import { maxLiquidityForAmounts } from '../utils/maxLiquidityForAmounts' -import { tickToPrice } from '../utils/priceTickConversions' -import { SqrtPriceMath } from '../utils/sqrtPriceMath' -import { TickMath } from '../utils/tickMath' -import { encodeSqrtRatioX96BigInt } from '../utils/encodeSqrtRatioX96' -import { Pool, TransactionOverrides } from './pool' +import { ZERO } from '../internalConstants.js' +import { maxLiquidityForAmounts } from '../utils/maxLiquidityForAmounts.js' +import { tickToPrice } from '../utils/priceTickConversions.js' +import { SqrtPriceMath } from '../utils/sqrtPriceMath.js' +import { TickMath } from '../utils/tickMath.js' +import { encodeSqrtRatioX96BigInt } from '../utils/encodeSqrtRatioX96.js' +import { Pool, TransactionOverrides } from './pool.js' import { ethers } from 'ethers' import INonfungiblePositionManager from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json' -import { ERC20_ABI } from '../constants' -import { bigIntFromBigintIsh } from '../utils/bigintIsh' +import { ERC20_ABI } from '../constants.js' +import { bigIntFromBigintIsh } from '../utils/bigintIsh.js' import { CollectOptions, IncreaseOptions, MintOptions, NonfungiblePositionManager, RemoveLiquidityOptions, -} from '../nonfungiblePositionManager' +} from '../nonfungiblePositionManager.js' interface PositionConstructorArgs { pool: Pool diff --git a/src/entities/route.ts b/src/entities/route.ts index 7b7d6ff8..1fee7c70 100644 --- a/src/entities/route.ts +++ b/src/entities/route.ts @@ -1,7 +1,7 @@ import invariant from 'tiny-invariant' import { Currency, Price, Token } from '@uniswap/sdk-core' -import { Pool } from './pool' +import { Pool } from './pool.js' /** * Represents a list of pools through which a swap can occur diff --git a/src/entities/rpcTickDataProvider.ts b/src/entities/rpcTickDataProvider.ts index 9ed4a4fa..60d078a0 100644 --- a/src/entities/rpcTickDataProvider.ts +++ b/src/entities/rpcTickDataProvider.ts @@ -1,10 +1,10 @@ import { BigintIsh } from '@uniswap/sdk-core' -import { TickList } from '../utils/tickList' -import { Tick } from './tick' -import { TickDataProvider } from './tickDataProvider' +import { TickList } from '../utils/tickList.js' +import { Tick } from './tick.js' +import { TickDataProvider } from './tickDataProvider.js' import { ethers } from 'ethers' -import { TickMath } from '../utils' -import { RPCPool } from '../utils/rpcPool' +import { TickMath } from '../utils/index.js' +import { RPCPool } from '../utils/rpcPool.js' /** * A data provider for ticks that is backed by an in-memory array of ticks. diff --git a/src/entities/tick.ts b/src/entities/tick.ts index 6f92848c..7742c099 100644 --- a/src/entities/tick.ts +++ b/src/entities/tick.ts @@ -1,8 +1,8 @@ import JSBI from 'jsbi' import invariant from 'tiny-invariant' import { BigintIsh } from '@uniswap/sdk-core' -import { TickMath } from '../utils' -import { bigIntFromBigintIsh } from '../utils/bigintIsh' +import { TickMath } from '../utils/index.js' +import { bigIntFromBigintIsh } from '../utils/bigintIsh.js' export interface TickConstructorArgs { index: number diff --git a/src/entities/tickListDataProvider.ts b/src/entities/tickListDataProvider.ts index c226e5ae..f4abedcc 100644 --- a/src/entities/tickListDataProvider.ts +++ b/src/entities/tickListDataProvider.ts @@ -1,7 +1,7 @@ import { BigintIsh } from '@uniswap/sdk-core' -import { TickList } from '../utils/tickList' -import { Tick, TickConstructorArgs } from './tick' -import { TickDataProvider } from './tickDataProvider' +import { TickList } from '../utils/tickList.js' +import { Tick, TickConstructorArgs } from './tick.js' +import { TickDataProvider } from './tickDataProvider.js' /** * A data provider for ticks that is backed by an in-memory array of ticks. diff --git a/src/entities/trade.ts b/src/entities/trade.ts index aabb990c..cdaff248 100644 --- a/src/entities/trade.ts +++ b/src/entities/trade.ts @@ -1,8 +1,8 @@ import { Currency, Fraction, Percent, Price, sortedInsert, CurrencyAmount, TradeType, Token } from '@uniswap/sdk-core' import invariant from 'tiny-invariant' -import { ONE, ZERO } from '../internalConstants' -import { Pool } from './pool' -import { Route } from './route' +import { ONE, ZERO } from '../internalConstants.js' +import { Pool } from './pool.js' +import { Route } from './route.js' /** * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them diff --git a/src/index.ts b/src/index.ts index ac5dc03f..261fa7b5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ -export * from './entities' -export * from './utils' +export * from './entities/index.js' +export * from './utils/index.js' -export * from './constants' -export * from './multicall' -export * from './nonfungiblePositionManager' -export * from './payments' -export * from './quoter' -export * from './selfPermit' -export * from './staker' -export * from './swapRouter' +export * from './constants.js' +export * from './multicall.js' +export * from './nonfungiblePositionManager.js' +export * from './payments.js' +export * from './quoter.js' +export * from './selfPermit.js' +export * from './staker.js' +export * from './swapRouter.js' diff --git a/src/nonfungiblePositionManager.ts b/src/nonfungiblePositionManager.ts index 2db6efec..84dc5eca 100644 --- a/src/nonfungiblePositionManager.ts +++ b/src/nonfungiblePositionManager.ts @@ -9,17 +9,17 @@ import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, } from '@uniswap/sdk-core' import invariant from 'tiny-invariant' -import { Position } from './entities/position' -import { MethodParameters, toHex } from './utils/calldata' +import { Position } from './entities/position.js' +import { MethodParameters, toHex } from './utils/calldata.js' import { Interface } from '@ethersproject/abi' import INonfungiblePositionManager from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json' -import { PermitOptions, SelfPermit } from './selfPermit' -import { ADDRESS_ZERO } from './constants' -import { Pool, TransactionOverrides } from './entities' -import { Multicall } from './multicall' -import { Payments } from './payments' +import { PermitOptions, SelfPermit } from './selfPermit.js' +import { ADDRESS_ZERO } from './constants.js' +import { Pool, TransactionOverrides } from './entities/index.js' +import { Multicall } from './multicall.js' +import { Payments } from './payments.js' import { ethers } from 'ethers' -import { bigIntFromBigintIsh } from './utils/bigintIsh' +import { bigIntFromBigintIsh } from './utils/bigintIsh.js' const MaxUint128 = `0x${(2n ** 128n - 1n).toString(16)}` diff --git a/src/payments.ts b/src/payments.ts index 78cb0583..a11fdc97 100644 --- a/src/payments.ts +++ b/src/payments.ts @@ -1,7 +1,7 @@ import { Interface } from '@ethersproject/abi' import IPeripheryPaymentsWithFee from '@uniswap/v3-periphery/artifacts/contracts/interfaces/IPeripheryPaymentsWithFee.sol/IPeripheryPaymentsWithFee.json' import { BigintIsh, Percent, Token, validateAndParseAddress } from '@uniswap/sdk-core' -import { toHex } from './utils/calldata' +import { toHex } from './utils/calldata.js' export interface FeeOptions { /** diff --git a/src/quoter.ts b/src/quoter.ts index 862706db..9bec06f8 100644 --- a/src/quoter.ts +++ b/src/quoter.ts @@ -12,12 +12,12 @@ import { ChainId, Token, } from '@uniswap/sdk-core' -import { encodeRouteToPath, MethodParameters, toHex } from './utils' +import { encodeRouteToPath, MethodParameters, toHex } from './utils/index.js' import IQuoter from '@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json' import IQuoterV2 from '@uniswap/swap-router-contracts/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json' -import { Route } from './entities' +import { Route } from './entities/index.js' import invariant from 'tiny-invariant' -import { FeeAmount } from './constants' +import { FeeAmount } from './constants.js' /** * Optional arguments to send to the quoter. diff --git a/src/selfPermit.ts b/src/selfPermit.ts index 99cf9d70..900dbd99 100644 --- a/src/selfPermit.ts +++ b/src/selfPermit.ts @@ -1,7 +1,7 @@ import { BigintIsh, Token } from '@uniswap/sdk-core' import { Interface } from '@ethersproject/abi' import ISelfPermit from '@uniswap/v3-periphery/artifacts/contracts/interfaces/ISelfPermit.sol/ISelfPermit.json' -import { toHex } from './utils' +import { toHex } from './utils/index.js' export interface StandardPermitArguments { v: 0 | 1 | 27 | 28 diff --git a/src/staker.ts b/src/staker.ts index 137e38eb..105a41ed 100644 --- a/src/staker.ts +++ b/src/staker.ts @@ -1,9 +1,9 @@ import { BigintIsh, Token, validateAndParseAddress } from '@uniswap/sdk-core' -import { MethodParameters, toHex } from './utils/calldata' +import { MethodParameters, toHex } from './utils/calldata.js' import { defaultAbiCoder, Interface } from '@ethersproject/abi' import IUniswapV3Staker from '@uniswap/v3-staker/artifacts/contracts/UniswapV3Staker.sol/UniswapV3Staker.json' -import { Pool } from './entities' -import { Multicall } from './multicall' +import { Pool } from './entities/index.js' +import { Multicall } from './multicall.js' export type FullWithdrawOptions = ClaimOptions & WithdrawOptions /** diff --git a/src/swapRouter.ts b/src/swapRouter.ts index 604ac0a0..814eefcd 100644 --- a/src/swapRouter.ts +++ b/src/swapRouter.ts @@ -13,18 +13,18 @@ import { ChainId, } from '@uniswap/sdk-core' import invariant from 'tiny-invariant' -import { BestTradeOptions, Trade } from './entities/trade' -import { ADDRESS_ZERO } from './constants' -import { PermitOptions, SelfPermit } from './selfPermit' -import { approveTokenTransfer, encodeRouteToPath, getAllowance } from './utils' -import { MethodParameters, toHex } from './utils/calldata' +import { BestTradeOptions, Trade } from './entities/trade.js' +import { ADDRESS_ZERO } from './constants.js' +import { PermitOptions, SelfPermit } from './selfPermit.js' +import { approveTokenTransfer, encodeRouteToPath, getAllowance } from './utils/index.js' +import { MethodParameters, toHex } from './utils/calldata.js' import ISwapRouter from '@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json' -import { Multicall } from './multicall' -import { FeeOptions, Payments } from './payments' -import { Pool } from './entities/pool' -import { Route } from './entities/route' -import { SwapQuoter } from './quoter' -import { fetchTickDataForAllPoolsInRoute } from './utils/fetchTicksForRoute' +import { Multicall } from './multicall.js' +import { FeeOptions, Payments } from './payments.js' +import { Pool } from './entities/pool.js' +import { Route } from './entities/route.js' +import { SwapQuoter } from './quoter.js' +import { fetchTickDataForAllPoolsInRoute } from './utils/fetchTicksForRoute.js' /** * Options for producing the arguments to send calls to the router. diff --git a/src/utils/approveTokenTransfer.ts b/src/utils/approveTokenTransfer.ts index 7b989fcb..18b321be 100644 --- a/src/utils/approveTokenTransfer.ts +++ b/src/utils/approveTokenTransfer.ts @@ -2,7 +2,7 @@ import { Signer } from '@ethersproject/abstract-signer' import { Provider, TransactionReceipt, TransactionResponse } from '@ethersproject/abstract-provider' import { Contract } from '@ethersproject/contracts' import { BigintIsh } from '@uniswap/sdk-core' -import { ERC20_ABI } from '../constants' +import { ERC20_ABI } from '../constants.js' import { BigNumber } from 'ethers' /** diff --git a/src/utils/calldata.ts b/src/utils/calldata.ts index 51e3086e..374dcaac 100644 --- a/src/utils/calldata.ts +++ b/src/utils/calldata.ts @@ -1,5 +1,5 @@ import { BigintIsh } from '@uniswap/sdk-core' -import { bigIntFromBigintIsh } from './bigintIsh' +import { bigIntFromBigintIsh } from './bigintIsh.js' /** * Generated method parameters for executing a call. diff --git a/src/utils/computePoolAddress.ts b/src/utils/computePoolAddress.ts index 5395eb55..4c98f26c 100644 --- a/src/utils/computePoolAddress.ts +++ b/src/utils/computePoolAddress.ts @@ -2,7 +2,7 @@ import { defaultAbiCoder } from '@ethersproject/abi' import { getCreate2Address } from '@ethersproject/address' import { keccak256 } from '@ethersproject/solidity' import { Token } from '@uniswap/sdk-core' -import { FeeAmount, POOL_INIT_CODE_HASH } from '../constants' +import { FeeAmount, POOL_INIT_CODE_HASH } from '../constants.js' /** * Computes a pool address diff --git a/src/utils/encodeRouteToPath.ts b/src/utils/encodeRouteToPath.ts index 83c64d38..f734ebcc 100644 --- a/src/utils/encodeRouteToPath.ts +++ b/src/utils/encodeRouteToPath.ts @@ -1,7 +1,7 @@ import { pack } from '@ethersproject/solidity' import { Currency, Token } from '@uniswap/sdk-core' -import { Pool } from '../entities/pool' -import { Route } from '../entities/route' +import { Pool } from '../entities/pool.js' +import { Route } from '../entities/route.js' /** * Converts a route to a hex encoded path diff --git a/src/utils/encodeSqrtRatioX96.ts b/src/utils/encodeSqrtRatioX96.ts index b45749fa..fa430107 100644 --- a/src/utils/encodeSqrtRatioX96.ts +++ b/src/utils/encodeSqrtRatioX96.ts @@ -1,6 +1,6 @@ import JSBI from 'jsbi' import { BigintIsh, sqrt } from '@uniswap/sdk-core' -import { bigIntFromBigintIsh } from './bigintIsh' +import { bigIntFromBigintIsh } from './bigintIsh.js' /** * Returns the sqrt ratio as a Q64.96 corresponding to a given ratio of amount1 and amount0 diff --git a/src/utils/fetchTicksForRoute.ts b/src/utils/fetchTicksForRoute.ts index fd2a3f8a..e86ff47c 100644 --- a/src/utils/fetchTicksForRoute.ts +++ b/src/utils/fetchTicksForRoute.ts @@ -1,7 +1,7 @@ import { Currency } from '@uniswap/sdk-core' -import { Route } from '../entities/route' +import { Route } from '../entities/route.js' import { Provider } from '@ethersproject/abstract-provider' -import { NoTickDataProvider } from '../entities' +import { NoTickDataProvider } from '../entities/index.js' import invariant from 'tiny-invariant' export async function fetchTickDataForAllPoolsInRoute( diff --git a/src/utils/fullMath.ts b/src/utils/fullMath.ts index 8a15bd97..30eb63f2 100644 --- a/src/utils/fullMath.ts +++ b/src/utils/fullMath.ts @@ -1,5 +1,5 @@ import JSBI from 'jsbi' -import { bigIntFromBigintIsh } from './bigintIsh' +import { bigIntFromBigintIsh } from './bigintIsh.js' export abstract class FullMath { /** diff --git a/src/utils/index.ts b/src/utils/index.ts index 48503348..f257ff0d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,18 +1,18 @@ -export * from './calldata' -export * from './computePoolAddress' -export * from './encodeRouteToPath' -export * from './encodeSqrtRatioX96' -export * from './fullMath' -export * from './isSorted' -export * from './liquidityMath' -export * from './maxLiquidityForAmounts' -export * from './mostSignificantBit' -export * from './nearestUsableTick' -export * from './position' -export * from './priceTickConversions' -export * from './sqrtPriceMath' -export * from './swapMath' -export * from './tickLibrary' -export * from './tickList' -export * from './tickMath' -export * from './approveTokenTransfer' +export * from './calldata.js' +export * from './computePoolAddress.js' +export * from './encodeRouteToPath.js' +export * from './encodeSqrtRatioX96.js' +export * from './fullMath.js' +export * from './isSorted.js' +export * from './liquidityMath.js' +export * from './maxLiquidityForAmounts.js' +export * from './mostSignificantBit.js' +export * from './nearestUsableTick.js' +export * from './position.js' +export * from './priceTickConversions.js' +export * from './sqrtPriceMath.js' +export * from './swapMath.js' +export * from './tickLibrary.js' +export * from './tickList.js' +export * from './tickMath.js' +export * from './approveTokenTransfer.js' diff --git a/src/utils/liquidityMath.ts b/src/utils/liquidityMath.ts index 2cd263b4..d46192a8 100644 --- a/src/utils/liquidityMath.ts +++ b/src/utils/liquidityMath.ts @@ -1,5 +1,5 @@ import JSBI from 'jsbi' -import { bigIntFromBigintIsh } from './bigintIsh' +import { bigIntFromBigintIsh } from './bigintIsh.js' export abstract class LiquidityMath { /** diff --git a/src/utils/maxLiquidityForAmounts.ts b/src/utils/maxLiquidityForAmounts.ts index 358c2eed..ecd76e80 100644 --- a/src/utils/maxLiquidityForAmounts.ts +++ b/src/utils/maxLiquidityForAmounts.ts @@ -1,7 +1,7 @@ import { BigintIsh } from '@uniswap/sdk-core' import JSBI from 'jsbi' -import { Q96_BIGINT } from '../internalConstants' -import { bigIntFromBigintIsh } from './bigintIsh' +import { Q96_BIGINT } from '../internalConstants.js' +import { bigIntFromBigintIsh } from './bigintIsh.js' /** * Returns an imprecise maximum amount of liquidity received for a given amount of token 0. diff --git a/src/utils/mostSignificantBit.ts b/src/utils/mostSignificantBit.ts index 2ba5b50d..9f8169d8 100644 --- a/src/utils/mostSignificantBit.ts +++ b/src/utils/mostSignificantBit.ts @@ -1,7 +1,7 @@ import { MaxUint256BigInt } from '@uniswap/sdk-core' import JSBI from 'jsbi' import invariant from 'tiny-invariant' -import { bigIntFromBigintIsh } from './bigintIsh' +import { bigIntFromBigintIsh } from './bigintIsh.js' const POWERS_OF_2 = [128, 64, 32, 16, 8, 4, 2, 1].map((pow: number): [number, bigint] => [pow, 2n ** BigInt(pow)]) diff --git a/src/utils/nearestUsableTick.ts b/src/utils/nearestUsableTick.ts index 90b4839d..675cbd78 100644 --- a/src/utils/nearestUsableTick.ts +++ b/src/utils/nearestUsableTick.ts @@ -1,5 +1,5 @@ import invariant from 'tiny-invariant' -import { TickMath } from './tickMath' +import { TickMath } from './tickMath.js' /** * Returns the closest tick that is nearest a given tick and usable for the given tick spacing diff --git a/src/utils/position.ts b/src/utils/position.ts index e8d27c36..cb2181f4 100644 --- a/src/utils/position.ts +++ b/src/utils/position.ts @@ -1,6 +1,6 @@ import JSBI from 'jsbi' -import { subIn256 } from './tickLibrary' -import { bigIntFromBigintIsh } from './bigintIsh' +import { subIn256 } from './tickLibrary.js' +import { bigIntFromBigintIsh } from './bigintIsh.js' const Q128 = 2n ** 128n diff --git a/src/utils/priceTickConversions.ts b/src/utils/priceTickConversions.ts index d3f179a2..ff0be6a3 100644 --- a/src/utils/priceTickConversions.ts +++ b/src/utils/priceTickConversions.ts @@ -1,7 +1,7 @@ import { Price, Token } from '@uniswap/sdk-core' -import { Q192 } from '../internalConstants' -import { encodeSqrtRatioX96BigInt } from './encodeSqrtRatioX96' -import { TickMath } from './tickMath' +import { Q192 } from '../internalConstants.js' +import { encodeSqrtRatioX96BigInt } from './encodeSqrtRatioX96.js' +import { TickMath } from './tickMath.js' /** * Returns a price object corresponding to the input tick and the base/quote token diff --git a/src/utils/rpcPool.ts b/src/utils/rpcPool.ts index 49929098..1441ad2b 100644 --- a/src/utils/rpcPool.ts +++ b/src/utils/rpcPool.ts @@ -1,5 +1,5 @@ import { Token } from '@uniswap/sdk-core' -import { FeeAmount, Tick } from '../' +import { FeeAmount, Tick } from '../index.js' import { ethers } from 'ethers' import poolAbi from '@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json' import { AbiCoder } from '@ethersproject/abi' diff --git a/src/utils/sqrtPriceMath.ts b/src/utils/sqrtPriceMath.ts index 735fbf5d..0c899f00 100644 --- a/src/utils/sqrtPriceMath.ts +++ b/src/utils/sqrtPriceMath.ts @@ -1,9 +1,9 @@ import { MaxUint256BigInt } from '@uniswap/sdk-core' import JSBI from 'jsbi' import invariant from 'tiny-invariant' -import { Q96_BIGINT } from '../internalConstants' -import { FullMath } from './fullMath' -import { bigIntFromBigintIsh } from './bigintIsh' +import { Q96_BIGINT } from '../internalConstants.js' +import { FullMath } from './fullMath.js' +import { bigIntFromBigintIsh } from './bigintIsh.js' const MaxUint160 = 2n ** 160n - 1n diff --git a/src/utils/swapMath.ts b/src/utils/swapMath.ts index 7101493d..19725513 100644 --- a/src/utils/swapMath.ts +++ b/src/utils/swapMath.ts @@ -1,8 +1,8 @@ import JSBI from 'jsbi' -import { FeeAmount } from '../constants' -import { FullMath } from './fullMath' -import { SqrtPriceMath } from './sqrtPriceMath' -import { bigIntFromBigintIsh } from './bigintIsh' +import { FeeAmount } from '../constants.js' +import { FullMath } from './fullMath.js' +import { SqrtPriceMath } from './sqrtPriceMath.js' +import { bigIntFromBigintIsh } from './bigintIsh.js' const MAX_FEE = 10n ** 6n diff --git a/src/utils/tickLibrary.ts b/src/utils/tickLibrary.ts index 452378d1..f4cd1481 100644 --- a/src/utils/tickLibrary.ts +++ b/src/utils/tickLibrary.ts @@ -1,5 +1,5 @@ import JSBI from 'jsbi' -import { bigIntFromBigintIsh } from './bigintIsh' +import { bigIntFromBigintIsh } from './bigintIsh.js' interface FeeGrowthOutside { feeGrowthOutside0X128: T diff --git a/src/utils/tickList.ts b/src/utils/tickList.ts index d356c65b..7c0a58f0 100644 --- a/src/utils/tickList.ts +++ b/src/utils/tickList.ts @@ -1,6 +1,6 @@ import invariant from 'tiny-invariant' -import { Tick } from '../entities/tick' -import { isSorted } from './isSorted' +import { Tick } from '../entities/tick.js' +import { isSorted } from './isSorted.js' function tickComparator(a: Tick, b: Tick) { return a.index - b.index diff --git a/src/utils/tickMath.ts b/src/utils/tickMath.ts index d3564c90..9e9e5221 100644 --- a/src/utils/tickMath.ts +++ b/src/utils/tickMath.ts @@ -1,8 +1,8 @@ import { MaxUint256BigInt } from '@uniswap/sdk-core' import JSBI from 'jsbi' import invariant from 'tiny-invariant' -import { mostSignificantBit } from './mostSignificantBit' -import { bigIntFromBigintIsh } from './bigintIsh' +import { mostSignificantBit } from './mostSignificantBit.js' +import { bigIntFromBigintIsh } from './bigintIsh.js' function mulShift(val: bigint, mulBy: bigint): bigint { return (val * mulBy) >> 128n diff --git a/src/v3migrator.ts b/src/v3migrator.ts index d4fd0d4c..3ae088f2 100644 --- a/src/v3migrator.ts +++ b/src/v3migrator.ts @@ -1,6 +1,6 @@ import { Percent, validateAndParseAddress, SUPPORTED_CHAINS, CHAIN_TO_ADDRESSES_MAP } from '@uniswap/sdk-core' -import { Pool } from './entities/pool' -import { MethodParameters, toHex } from './utils' +import { Pool } from './entities/pool.js' +import { MethodParameters, toHex } from './utils/index.js' import { Provider } from '@ethersproject/abstract-provider' import { Signer } from '@ethersproject/abstract-signer' import { TransactionResponse } from '@ethersproject/providers' diff --git a/yarn.lock b/yarn.lock index 6bd427dc..3a8942ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -138,9 +138,9 @@ integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw== "@babel/helpers@^7.23.7": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.7.tgz#eb543c36f81da2873e47b76ee032343ac83bba60" - integrity sha512-6AMnjCoC8wjqBzDHkuqpa7jAKwvMo4dC+lr/TFBz+ucfulO1XMpDnwWPGBNwClOKZ8h6xn5N81W/R5OrcKtCbQ== + version "7.23.8" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.8.tgz#fc6b2d65b16847fd50adddbd4232c76378959e34" + integrity sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ== dependencies: "@babel/template" "^7.22.15" "@babel/traverse" "^7.23.7" @@ -1006,9 +1006,9 @@ parse5 "^7.0.0" "@types/node@*": - version "20.10.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.6.tgz#a3ec84c22965802bf763da55b2394424f22bfbb5" - integrity sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw== + version "20.10.8" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.8.tgz#f1e223cbde9e25696661d167a5b93a9b2a5d57c7" + integrity sha512-f8nQs3cLxbAFc00vEU59yf9UyGUftkPaLGfvbVOIDdx2i1b8epBqj2aNGyP19fiyXWvlmZ7qC1XLjAzw/OKIeA== dependencies: undici-types "~5.26.4" @@ -1046,10 +1046,10 @@ resolved "https://registry.yarnpkg.com/@uniswap/lib/-/lib-4.0.1-alpha.tgz#2881008e55f075344675b3bca93f020b028fbd02" integrity sha512-f6UIliwBbRsgVLxIaBANF6w09tYqc6Y/qXdsrbEmXHyFA7ILiKrIwRFXe1yOg8M3cksgVsO9N7yuL2DdCGQKBA== -"@uniswap/sdk-core@npm:@uniswapfoundation/sdk-core@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@uniswapfoundation/sdk-core/-/sdk-core-5.0.0.tgz#314d1c191167f6bfe6bb5a98736e1f9e13b7e652" - integrity sha512-fAB3ekjG86tw85ZEMlShiqQw3dc6ENBNTRifXw8NJbf7rDGT27Cd93v/JOr85OXWRaUeR6G5fBKQkQ3FCCmNtg== +"@uniswap/sdk-core@npm:@uniswapfoundation/sdk-core@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@uniswapfoundation/sdk-core/-/sdk-core-5.0.1.tgz#c93bfb108154998d861a1c4b228c83865afa04ad" + integrity sha512-hhdMZh93k4r3sUQ6GAuNGaeYX+a4Dnp4ZqPvvV6SAjHb97hExItKmZJuNnmCDXllFGkTzaVz9SxxJ3Be8pyRpg== dependencies: "@ethersproject/address" "^5.0.2" big.js "^5.2.2" @@ -1356,9 +1356,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001565: - version "1.0.30001574" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001574.tgz#fb4f1359c77f6af942510493672e1ec7ec80230c" - integrity sha512-BtYEK4r/iHt/txm81KBudCUcTy7t+s9emrIaHqjYurQ10x71zJ5VQ9x1dYPcz/b+pKSp4y/v1xSI67A+LzpNyg== + version "1.0.30001576" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001576.tgz#893be772cf8ee6056d6c1e2d07df365b9ec0a5c4" + integrity sha512-ff5BdakGe2P3SQsMsiqmt1Lc8221NR1VzHj5jXN5vBny9A6fpze94HiVV/n7XRosOlsShJcvMv5mdnpjOGCEgg== chalk@^2.0.1, chalk@^2.4.2: version "2.4.2" @@ -1580,9 +1580,9 @@ dotenv@^14.2.0: integrity sha512-vwEppIphpFdvaMCaHfCEv9IgwcxMljMw2TnAQBB4VWPvzXQLTb82jwmdOKzlEVUL3gNFT4l4TPKO+Bn+sqcrVQ== electron-to-chromium@^1.4.601: - version "1.4.622" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.622.tgz#925d8b2264abbcbe264a9a6290d97b9e5a1af205" - integrity sha512-GZ47DEy0Gm2Z8RVG092CkFvX7SdotG57c4YZOe8W8qD4rOmk3plgeNmiLVRHP/Liqj1wRiY3uUUod9vb9hnxZA== + version "1.4.626" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.626.tgz#c20e1706354a31721b65e81496800534dd04b222" + integrity sha512-f7/be56VjRRQk+Ric6PmIrEtPcIqsn3tElyAu9Sh6egha2VLJ82qwkcOdcnT06W+Pb6RUulV1ckzrGbKzVcTHg== elliptic@6.5.4: version "6.5.4" From 0c6f8f782d549e1ab569e1448645e5a51240a717 Mon Sep 17 00:00:00 2001 From: Koray Koska <11356621+koraykoska@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:25:10 +0100 Subject: [PATCH 2/2] chore: bump version to 4.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0bacacc..0b8ee73b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "publishConfig": { "access": "public" }, - "version": "4.0.2", + "version": "4.0.3", "description": "⚒️ An SDK for building applications on top of Uniswap V3", "main": "dist/index.js", "typings": "dist/index.d.ts",