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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/abis/algebraPositionManager.d.ts +1083 -0
  4. package/dist/abis/algebraSwapRouter.d.ts +499 -0
  5. package/dist/abis/index.d.ts +3 -0
  6. package/dist/abis/selfPermit.d.ts +121 -0
  7. package/dist/classes/index.d.ts +3 -0
  8. package/dist/classes/nonfungiblePositionManager.d.ts +145 -0
  9. package/dist/classes/selfPermit.d.ts +22 -0
  10. package/dist/classes/swapRouter.d.ts +67 -0
  11. package/dist/constants/addresses.d.ts +6 -0
  12. package/dist/constants/chainIds.d.ts +3 -0
  13. package/dist/constants/constants.d.ts +3 -0
  14. package/dist/constants/index.d.ts +4 -0
  15. package/dist/constants/internalConstants.d.ts +7 -0
  16. package/dist/entities/AbstractCurrency.d.ts +48 -0
  17. package/dist/entities/Currency.d.ts +3 -0
  18. package/dist/entities/CurrencyAmount.d.ts +32 -0
  19. package/dist/entities/ExtendedNative.d.ts +7 -0
  20. package/dist/entities/Fraction.d.ts +25 -0
  21. package/dist/entities/Native.d.ts +13 -0
  22. package/dist/entities/NativeCurrency.d.ts +8 -0
  23. package/dist/entities/Percent.d.ts +16 -0
  24. package/dist/entities/Price.d.ts +39 -0
  25. package/dist/entities/Token.d.ts +32 -0
  26. package/dist/entities/index.d.ts +17 -0
  27. package/dist/entities/pool.d.ts +86 -0
  28. package/dist/entities/position.d.ts +135 -0
  29. package/dist/entities/route.d.ts +28 -0
  30. package/dist/entities/tick.d.ts +13 -0
  31. package/dist/entities/tickDataProvider.d.ts +31 -0
  32. package/dist/entities/tickListDataProvider.d.ts +15 -0
  33. package/dist/entities/trade.d.ts +224 -0
  34. package/dist/entities/wnative.d.ts +7 -0
  35. package/dist/enums/bound.d.ts +4 -0
  36. package/dist/enums/field.d.ts +4 -0
  37. package/dist/enums/index.d.ts +4 -0
  38. package/dist/enums/rounding.d.ts +5 -0
  39. package/dist/enums/tradeType.d.ts +4 -0
  40. package/dist/functions/index.d.ts +5 -0
  41. package/dist/functions/maxAmountSpend.d.ts +7 -0
  42. package/dist/functions/mint.d.ts +3 -0
  43. package/dist/functions/retry.d.ts +22 -0
  44. package/dist/functions/tryParseAmount.d.ts +3 -0
  45. package/dist/functions/unwrappedToken.d.ts +2 -0
  46. package/dist/index.d.ts +8 -0
  47. package/dist/index.js +8 -0
  48. package/dist/monad-v3-sdk.cjs.development.js +5458 -0
  49. package/dist/monad-v3-sdk.cjs.development.js.map +1 -0
  50. package/dist/monad-v3-sdk.cjs.production.min.js +2 -0
  51. package/dist/monad-v3-sdk.cjs.production.min.js.map +1 -0
  52. package/dist/monad-v3-sdk.esm.js +5395 -0
  53. package/dist/monad-v3-sdk.esm.js.map +1 -0
  54. package/dist/types/BigIntish.d.ts +2 -0
  55. package/dist/types/index.d.ts +1 -0
  56. package/dist/utils/calldata.d.ts +20 -0
  57. package/dist/utils/chunkArray.d.ts +2 -0
  58. package/dist/utils/computePoolAddress.d.ts +28 -0
  59. package/dist/utils/computeSurroundingTicks.d.ts +2 -0
  60. package/dist/utils/encodeRouteToPath.d.ts +8 -0
  61. package/dist/utils/encodeSqrtRatioX96.d.ts +9 -0
  62. package/dist/utils/format.d.ts +14 -0
  63. package/dist/utils/formatTickPrice.d.ts +5 -0
  64. package/dist/utils/fullMath.d.ts +7 -0
  65. package/dist/utils/getRatio.d.ts +2 -0
  66. package/dist/utils/getTickToPrice.d.ts +2 -0
  67. package/dist/utils/index.d.ts +15 -0
  68. package/dist/utils/isSorted.d.ts +7 -0
  69. package/dist/utils/liquidityMath.d.ts +7 -0
  70. package/dist/utils/maxLiquidityForAmounts.d.ts +14 -0
  71. package/dist/utils/mostSignificantBit.d.ts +2 -0
  72. package/dist/utils/nearestUsableTick.d.ts +6 -0
  73. package/dist/utils/priceTickConversions.d.ts +16 -0
  74. package/dist/utils/sortedInsert.d.ts +1 -0
  75. package/dist/utils/sqrt.d.ts +7 -0
  76. package/dist/utils/sqrtPriceMath.d.ts +12 -0
  77. package/dist/utils/stringToColour.d.ts +5 -0
  78. package/dist/utils/swapMath.d.ts +7 -0
  79. package/dist/utils/tickList.d.ts +22 -0
  80. package/dist/utils/tickMath.d.ts +33 -0
  81. package/dist/utils/validateAndParseAddress.d.ts +1 -0
  82. package/package.json +62 -0
@@ -0,0 +1,2 @@
1
+ import JSBI from 'jsbi';
2
+ export declare type BigintIsh = JSBI | number | string;
@@ -0,0 +1 @@
1
+ export * from './BigIntish';
@@ -0,0 +1,20 @@
1
+ import { BigintIsh } from '../types/BigIntish';
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 | 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,2 @@
1
+ export declare const DEFAULT_GAS_REQUIRED = 200000;
2
+ export default function chunkArray<T>(items: T[], gasLimit?: number): T[][];
@@ -0,0 +1,28 @@
1
+ import { Token } from '../entities';
2
+ /**
3
+ * Computes a pool address
4
+ * @param poolDeployer The Algebra Pool Deployer address
5
+ * @param tokenA The first token of the pair, irrespective of sort order
6
+ * @param tokenB The second token of the pair, irrespective of sort order
7
+ * @param initCodeHashManualOverride The initial code hash override
8
+ * @returns The pool address
9
+ */
10
+ export declare function computePoolAddress({ tokenA, tokenB, initCodeHashManualOverride, poolDeployer }: {
11
+ tokenA: Token;
12
+ tokenB: Token;
13
+ initCodeHashManualOverride?: string;
14
+ poolDeployer?: string;
15
+ }): string;
16
+ export declare function computeCustomPoolAddress({ tokenA, tokenB, customPoolDeployer, initCodeHashManualOverride, mainPoolDeployer }: {
17
+ tokenA: Token;
18
+ tokenB: Token;
19
+ customPoolDeployer: string;
20
+ initCodeHashManualOverride?: string;
21
+ mainPoolDeployer?: string;
22
+ }): string;
23
+ export declare function computePoolAddressZkSync({ poolDeployer, tokenA, tokenB, initCodeHashManualOverride, }: {
24
+ tokenA: Token;
25
+ tokenB: Token;
26
+ initCodeHashManualOverride?: string;
27
+ poolDeployer?: string;
28
+ }): string;
@@ -0,0 +1,2 @@
1
+ import { Token } from "../entities";
2
+ export default function computeSurroundingTicks(token0: Token, token1: Token, activeTickProcessed: any, sortedTickData: any, pivot: number, ascending: boolean): any[];
@@ -0,0 +1,8 @@
1
+ import { Route } from '../entities/route';
2
+ import { Currency } from "../entities";
3
+ /**
4
+ * Converts a route to a hex encoded path
5
+ * @param route the v3 path to convert to an encoded path
6
+ * @param exactOutput whether the route should be encoded in reverse, for making exact output swaps
7
+ */
8
+ export declare function encodeRouteToPath(route: Route<Currency, Currency>, exactOutput: boolean): string;
@@ -0,0 +1,9 @@
1
+ import JSBI from 'jsbi';
2
+ import { BigintIsh } from '../types/BigIntish';
3
+ /**
4
+ * Returns the sqrt ratio as a Q64.96 corresponding to a given ratio of amount1 and amount0
5
+ * @param amount1 The numerator amount i.e., the amount of token1
6
+ * @param amount0 The denominator amount i.e., the amount of token0
7
+ * @returns The sqrt ratio
8
+ */
9
+ export declare function encodeSqrtRatioX96(amount1: BigintIsh, amount0: BigintIsh): JSBI;
@@ -0,0 +1,14 @@
1
+ import { Currency, CurrencyAmount, Price } from '../entities';
2
+ import { BigNumberish } from '@ethersproject/bignumber';
3
+ export declare const capitalize: (s: any) => string;
4
+ export declare const formatK: (value: string) => any;
5
+ export declare function shortenAddress(address: string, chars?: number): string;
6
+ export declare function shortenString(string: string, length: number): string;
7
+ export declare function formatPercent(percentString: any): string;
8
+ export declare const formatNumber: (number: any, usd?: boolean, scale?: boolean) => string;
9
+ export declare function formatNumberScale(number: any, usd?: boolean, decimals?: number): string;
10
+ export declare function escapeRegExp(string: string): string;
11
+ export declare const formatBalance: (value: BigNumberish, decimals?: number, maxFraction?: number) => string;
12
+ export declare function formatCurrencyAmount(amount: CurrencyAmount<Currency> | undefined, sigFigs: number): string;
13
+ export declare function formatPrice(price: Price<Currency, Currency> | undefined, sigFigs: number): string;
14
+ export declare function formatDateAgo(date: Date): string;
@@ -0,0 +1,5 @@
1
+ import { Price, Token } from '../entities';
2
+ import { Bound } from "../enums/bound";
3
+ export declare function formatTickPrice(price: Price<Token, Token> | undefined, atLimit: {
4
+ [bound in Bound]?: boolean | undefined;
5
+ }, direction: Bound, placeholder?: string): string;
@@ -0,0 +1,7 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class FullMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ static mulDivRoundingUp(a: JSBI, b: JSBI, denominator: JSBI): JSBI;
7
+ }
@@ -0,0 +1,2 @@
1
+ import { Currency, Price } from '../entities';
2
+ export declare function getRatio(lower: Price<Currency, Currency>, current: Price<Currency, Currency>, upper: Price<Currency, Currency>): number | undefined;
@@ -0,0 +1,2 @@
1
+ import { Price, Token } from '../entities';
2
+ export declare function getTickToPrice(baseToken?: Token, quoteToken?: Token, tick?: number): Price<Token, Token> | undefined;
@@ -0,0 +1,15 @@
1
+ export * from './calldata';
2
+ export * from './computePoolAddress';
3
+ export * from './encodeRouteToPath';
4
+ export * from './encodeSqrtRatioX96';
5
+ export * from './fullMath';
6
+ export * from './isSorted';
7
+ export * from './liquidityMath';
8
+ export * from './maxLiquidityForAmounts';
9
+ export * from './mostSignificantBit';
10
+ export * from './nearestUsableTick';
11
+ export * from './priceTickConversions';
12
+ export * from './sqrtPriceMath';
13
+ export * from './tickMath';
14
+ export * from './tickList';
15
+ export * from './getTickToPrice';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Determines if a tick list is sorted
3
+ * @param list The tick list
4
+ * @param comparator The comparator
5
+ * @returns true if sorted
6
+ */
7
+ export declare function isSorted<T>(list: Array<T>, comparator: (a: T, b: T) => number): boolean;
@@ -0,0 +1,7 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class LiquidityMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ static addDelta(x: JSBI, y: JSBI): JSBI;
7
+ }
@@ -0,0 +1,14 @@
1
+ import { BigintIsh } from '../types/BigIntish';
2
+ import JSBI from 'jsbi';
3
+ /**
4
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
5
+ * and the prices at the tick boundaries.
6
+ * @param sqrtRatioCurrentX96 the current price
7
+ * @param sqrtRatioAX96 price at lower boundary
8
+ * @param sqrtRatioBX96 price at upper boundary
9
+ * @param amount0 token0 amount
10
+ * @param amount1 token1 amount
11
+ * @param useFullPrecision if false, liquidity will be maximized according to what the router can calculate,
12
+ * not what core can theoretically support
13
+ */
14
+ export declare function maxLiquidityForAmounts(sqrtRatioCurrentX96: JSBI, sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, amount0: BigintIsh, amount1: BigintIsh, useFullPrecision: boolean): JSBI;
@@ -0,0 +1,2 @@
1
+ import JSBI from 'jsbi';
2
+ export declare function mostSignificantBit(x: JSBI): number;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns the closest tick that is nearest a given tick and usable for the given tick spacing
3
+ * @param tick the target tick
4
+ * @param tickSpacing the spacing of the pool
5
+ */
6
+ export declare function nearestUsableTick(tick: number, tickSpacing: number): number;
@@ -0,0 +1,16 @@
1
+ import { Price } from '../entities/Price';
2
+ import { Token } from '../entities/Token';
3
+ /**
4
+ * Returns a price object corresponding to the input tick and the base/quote token
5
+ * Inputs must be tokens because the address order is used to interpret the price represented by the tick
6
+ * @param baseToken the base token of the price
7
+ * @param quoteToken the quote token of the price
8
+ * @param tick the tick for which to return the price
9
+ */
10
+ export declare function tickToPrice(baseToken: Token, quoteToken: Token, tick: number): Price<Token, Token>;
11
+ /**
12
+ * Returns the first tick for which the given price is greater than or equal to the tick price
13
+ * @param price for which to return the closest tick that represents a price less than or equal to the input price,
14
+ * i.e. the price of the returned tick is less than or equal to the input price
15
+ */
16
+ export declare function priceToClosestTick(price: Price<Token, Token>): number;
@@ -0,0 +1 @@
1
+ export declare function sortedInsert<T>(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null;
@@ -0,0 +1,7 @@
1
+ import JSBI from 'jsbi';
2
+ export declare const MAX_SAFE_INTEGER: JSBI;
3
+ /**
4
+ * Computes floor(sqrt(value))
5
+ * @param value the value for which to compute the square root, rounded down
6
+ */
7
+ export declare function sqrt(value: JSBI): JSBI;
@@ -0,0 +1,12 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class SqrtPriceMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ static getAmount0Delta(sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, liquidity: JSBI, roundUp: boolean): JSBI;
7
+ static getAmount1Delta(sqrtRatioAX96: JSBI, sqrtRatioBX96: JSBI, liquidity: JSBI, roundUp: boolean): JSBI;
8
+ static getNextSqrtPriceFromInput(sqrtPX96: JSBI, liquidity: JSBI, amountIn: JSBI, zeroForOne: boolean): JSBI;
9
+ static getNextSqrtPriceFromOutput(sqrtPX96: JSBI, liquidity: JSBI, amountOut: JSBI, zeroForOne: boolean): JSBI;
10
+ private static getNextSqrtPriceFromAmount0RoundingUp;
11
+ private static getNextSqrtPriceFromAmount1RoundingDown;
12
+ }
@@ -0,0 +1,5 @@
1
+ export declare const stringToColour: (str: string) => {
2
+ background: string;
3
+ text: string;
4
+ border: string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class SwapMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ static computeSwapStep(sqrtRatioCurrentX96: JSBI, sqrtRatioTargetX96: JSBI, liquidity: JSBI, amountRemaining: JSBI, feePips: number): [JSBI, JSBI, JSBI, JSBI];
7
+ }
@@ -0,0 +1,22 @@
1
+ import { Tick } from '../entities/tick';
2
+ /**
3
+ * Utility methods for interacting with sorted lists of ticks
4
+ */
5
+ export declare abstract class TickList {
6
+ /**
7
+ * Cannot be constructed
8
+ */
9
+ static validateList(ticks: Tick[], tickSpacing: number): void;
10
+ static isBelowSmallest(ticks: readonly Tick[], tick: number): boolean;
11
+ static isAtOrAboveLargest(ticks: readonly Tick[], tick: number): boolean;
12
+ static getTick(ticks: readonly Tick[], index: number): Tick;
13
+ static nextInitializedTick(ticks: readonly Tick[], tick: number, lte: boolean): Tick;
14
+ static nextInitializedTickWithinOneWord(ticks: readonly Tick[], tick: number, lte: boolean, tickSpacing: number): [number, boolean];
15
+ /**
16
+ * Finds the largest tick in the list of ticks that is less than or equal to tick
17
+ * @param ticks list of ticks
18
+ * @param tick tick to find the largest tick that is less than or equal to tick
19
+ * @private
20
+ */
21
+ private static binarySearch;
22
+ }
@@ -0,0 +1,33 @@
1
+ import JSBI from 'jsbi';
2
+ export declare abstract class TickMath {
3
+ /**
4
+ * Cannot be constructed.
5
+ */
6
+ /**
7
+ * The minimum tick that can be used on any pool.
8
+ */
9
+ static MIN_TICK: number;
10
+ /**
11
+ * The maximum tick that can be used on any pool.
12
+ */
13
+ static MAX_TICK: number;
14
+ /**
15
+ * The sqrt ratio corresponding to the minimum tick that could be used on any pool.
16
+ */
17
+ static MIN_SQRT_RATIO: JSBI;
18
+ /**
19
+ * The sqrt ratio corresponding to the maximum tick that could be used on any pool.
20
+ */
21
+ static MAX_SQRT_RATIO: JSBI;
22
+ /**
23
+ * Returns the sqrt ratio as a Q64.96 for the given tick. The sqrt ratio is computed as sqrt(1.0001)^tick
24
+ * @param tick the tick for which to compute the sqrt ratio
25
+ */
26
+ static getSqrtRatioAtTick(tick: number): JSBI;
27
+ /**
28
+ * Returns the tick corresponding to a given sqrt ratio, s.t. #getSqrtRatioAtTick(tick) <= sqrtRatioX96
29
+ * and #getSqrtRatioAtTick(tick + 1) > sqrtRatioX96
30
+ * @param sqrtRatioX96 the sqrt ratio as a Q64.96 for which to compute the tick
31
+ */
32
+ static getTickAtSqrtRatio(sqrtRatioX96: JSBI): number;
33
+ }
@@ -0,0 +1 @@
1
+ export declare function validateAndParseAddress(address: string): string;
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "license": "MIT",
3
+ "main": "dist/index.js",
4
+ "typings": "dist/index.d.ts",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "engines": {
12
+ "node": ">=10"
13
+ },
14
+ "scripts": {
15
+ "start": "tsdx watch",
16
+ "build": "tsdx build",
17
+ "lint": "tsdx lint",
18
+ "prepare": "tsdx build",
19
+ "size": "size-limit",
20
+ "analyze": "size-limit --why"
21
+ },
22
+ "husky": {
23
+ "hooks": {
24
+ "pre-commit": "tsdx lint"
25
+ }
26
+ },
27
+ "prettier": {
28
+ "printWidth": 80,
29
+ "semi": true,
30
+ "singleQuote": true,
31
+ "trailingComma": "es5"
32
+ },
33
+ "name": "monad-v3-sdk",
34
+ "author": "cryptoalgebra",
35
+ "module": "dist/sdk.esm.js",
36
+ "dependencies": {
37
+ "@ethersproject/abi": "^5.7.0",
38
+ "@ethersproject/address": "^5.7.0",
39
+ "@ethersproject/bignumber": "^5.8.0",
40
+ "@ethersproject/bytes": "^5.8.0",
41
+ "@ethersproject/keccak256": "^5.8.0",
42
+ "@ethersproject/solidity": "^5.7.0",
43
+ "@ethersproject/strings": "^5.8.0",
44
+ "@ethersproject/units": "^5.7.0",
45
+ "big.js": "^6.2.1",
46
+ "decimal.js-light": "^2.5.1",
47
+ "jsbi": "^3.2.5",
48
+ "numeral": "^2.0.6",
49
+ "tiny-invariant": "^1.3.1",
50
+ "tiny-warning": "^1.0.3",
51
+ "toformat": "^2.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@size-limit/preset-small-lib": "^9.0.0",
55
+ "husky": "^8.0.3",
56
+ "size-limit": "^9.0.0",
57
+ "tsdx": "^0.14.1",
58
+ "tslib": "^2.6.2",
59
+ "typescript": "^5.2.2"
60
+ },
61
+ "version": "2.1.0"
62
+ }