@stabbleorg/mclmm-sdk 0.1.0 → 0.1.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/config.d.ts +25 -0
- package/lib/api/config.d.ts.map +1 -0
- package/lib/api/index.d.ts +2 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/pools.d.ts +4 -10
- package/lib/api/pools.d.ts.map +1 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/constants.d.ts +5 -65
- package/lib/constants.d.ts.map +1 -1
- package/lib/index.js +122 -157
- package/lib/index.mjs +125 -157
- package/lib/position-manager.d.ts +1 -1
- package/lib/position-manager.d.ts.map +1 -1
- package/lib/types.d.ts +23 -19
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/index.d.ts +5 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ClmmConfig } from "../types";
|
|
2
|
+
import { ClmmApiConfig } from ".";
|
|
3
|
+
export declare class ClmmConfigApi {
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(config: ClmmApiConfig);
|
|
7
|
+
/**
|
|
8
|
+
* Fetch all configs
|
|
9
|
+
* @returns CLMM config information or null if not found
|
|
10
|
+
*/
|
|
11
|
+
getClmmConfigs(): Promise<ClmmConfig[] | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Handle API errors and convert to Error
|
|
14
|
+
* @param error - Error from axios
|
|
15
|
+
* @returns Error with appropriate message
|
|
16
|
+
*/
|
|
17
|
+
private handleApiError;
|
|
18
|
+
/**
|
|
19
|
+
* Check if error is a 404 Not Found
|
|
20
|
+
* @param error - Error to check
|
|
21
|
+
* @returns True if 404 error
|
|
22
|
+
*/
|
|
23
|
+
private isNotFoundError;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/api/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAIlC,qBAAa,aAAa;IAGZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAEV,MAAM,EAAE,aAAa;IAUlD;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;IAYpD;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAkCtB;;;;OAIG;IACH,OAAO,CAAC,eAAe;CAMxB"}
|
package/lib/api/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { ClmmConfigApi } from "./config";
|
|
1
2
|
import { PoolsApi } from "./pools";
|
|
2
3
|
export interface ClmmApiConfig {
|
|
3
4
|
/** Base URL for the API */
|
|
4
5
|
baseUrl: string;
|
|
5
|
-
/** Optional API key for authentication */
|
|
6
|
-
apiKey?: string;
|
|
7
6
|
/** Request timeout in milliseconds */
|
|
8
7
|
timeout?: number;
|
|
9
8
|
}
|
|
10
9
|
export declare class ClmmApi {
|
|
11
10
|
private readonly config;
|
|
12
11
|
readonly pools: PoolsApi;
|
|
12
|
+
readonly clmmConfig: ClmmConfigApi;
|
|
13
13
|
constructor(config: ClmmApiConfig);
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,OAAO;IAIN,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,SAAgB,KAAK,EAAE,QAAQ,CAAC;IAChC,SAAgB,UAAU,EAAE,aAAa,CAAC;gBAEb,MAAM,EAAE,aAAa;CAInD"}
|
package/lib/api/pools.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address } from "@solana/kit";
|
|
2
|
-
import {
|
|
2
|
+
import { PoolApiData } from "../types";
|
|
3
3
|
import { ClmmApiConfig } from ".";
|
|
4
4
|
export declare class PoolsApi {
|
|
5
5
|
private readonly config;
|
|
@@ -10,25 +10,19 @@ export declare class PoolsApi {
|
|
|
10
10
|
* @param poolAddress - Pool state address
|
|
11
11
|
* @returns Pool information or null if not found
|
|
12
12
|
*/
|
|
13
|
-
getPool(poolAddress: Address): Promise<
|
|
13
|
+
getPool(poolAddress: Address): Promise<PoolApiData | null>;
|
|
14
14
|
/**
|
|
15
15
|
* Fetch all pools
|
|
16
16
|
* @returns Array of pool information
|
|
17
17
|
*/
|
|
18
|
-
getAllPools(): Promise<
|
|
18
|
+
getAllPools(): Promise<PoolApiData[]>;
|
|
19
19
|
/**
|
|
20
20
|
* Fetch pools by token pair
|
|
21
21
|
* @param tokenA - First token mint
|
|
22
22
|
* @param tokenB - Second token mint
|
|
23
23
|
* @returns Array of pool information matching the token pair
|
|
24
24
|
*/
|
|
25
|
-
getPoolsByTokenPair(tokenA: Address, tokenB: Address): Promise<
|
|
26
|
-
/**
|
|
27
|
-
* Map API response to SDK PoolInfo type
|
|
28
|
-
* @param apiPool - API pool response
|
|
29
|
-
* @returns Transformed PoolInfo object
|
|
30
|
-
*/
|
|
31
|
-
private mapApiResponseToPoolInfo;
|
|
25
|
+
getPoolsByTokenPair(tokenA: Address, tokenB: Address): Promise<PoolApiData[]>;
|
|
32
26
|
/**
|
|
33
27
|
* Handle API errors and convert to Error
|
|
34
28
|
* @param error - Error from axios
|
package/lib/api/pools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pools.d.ts","sourceRoot":"","sources":["../../src/api/pools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pools.d.ts","sourceRoot":"","sources":["../../src/api/pools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAQlC,qBAAa,QAAQ;IAGP,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAEV,MAAM,EAAE,aAAa;IAUlD;;;;OAIG;IACG,OAAO,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAahE;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAS3C;;;;;OAKG;IACG,mBAAmB,CACvB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,WAAW,EAAE,CAAC;IAgBzB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAkCtB;;;;OAIG;IACH,OAAO,CAAC,eAAe;CAMxB"}
|
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.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AO,CAE5D"}
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Constants and configuration values for the Stabble CLMM SDK
|
|
3
3
|
*/
|
|
4
|
-
import type
|
|
4
|
+
import { type Address } from "@solana/kit";
|
|
5
5
|
import BN from "bn.js";
|
|
6
6
|
export declare const STABBLE_CLMM_PROGRAM_ID: Address;
|
|
7
7
|
export declare const METADATA_PROGRAM_ID: Address<"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s">;
|
|
@@ -44,70 +44,6 @@ export declare const DEFAULT_CONFIG: {
|
|
|
44
44
|
readonly RETRY_DELAY: 1000;
|
|
45
45
|
};
|
|
46
46
|
export declare const TICKS_PER_ARRAY = 60;
|
|
47
|
-
export declare const PRICE_PRECISION = 1000000;
|
|
48
|
-
export declare const LIQUIDITY_PRECISION = 1000000000000;
|
|
49
|
-
export declare const FEE_PRECISION = 1000000;
|
|
50
|
-
export declare const DEFAULT_COMPUTE_UNITS = 400000;
|
|
51
|
-
export declare const PRIORITY_FEE_MICRO_LAMPORTS = 1000;
|
|
52
|
-
export declare const WELL_KNOWN_TOKENS: {
|
|
53
|
-
readonly SOL: Address;
|
|
54
|
-
readonly USDC: Address;
|
|
55
|
-
readonly USDT: Address;
|
|
56
|
-
};
|
|
57
|
-
export declare const ERROR_MESSAGES: {
|
|
58
|
-
readonly 6000: "LOK error";
|
|
59
|
-
readonly 6001: "Not approved";
|
|
60
|
-
readonly 6002: "Invalid update config flag";
|
|
61
|
-
readonly 6003: "Account lack";
|
|
62
|
-
readonly 6004: "Must collect fees and rewards before closing position";
|
|
63
|
-
readonly 6005: "Minting amount should be greater than 0";
|
|
64
|
-
readonly 6006: "Tick out of range";
|
|
65
|
-
readonly 6007: "Lower tick must be below upper tick";
|
|
66
|
-
readonly 6008: "Tick must be >= minimum tick (-443636)";
|
|
67
|
-
readonly 6009: "Tick must be <= maximum tick (443636)";
|
|
68
|
-
readonly 6010: "Tick must be divisible by tick spacing";
|
|
69
|
-
readonly 6011: "Invalid tick array account";
|
|
70
|
-
readonly 6012: "Invalid tick array boundary";
|
|
71
|
-
readonly 6013: "Square root price limit overflow";
|
|
72
|
-
readonly 6014: "sqrt_price_x64 out of range";
|
|
73
|
-
readonly 6015: "Liquidity sub delta L must be smaller than before";
|
|
74
|
-
readonly 6016: "Liquidity add delta L must be >= before";
|
|
75
|
-
readonly 6017: "Invalid liquidity when updating position";
|
|
76
|
-
readonly 6018: "Both token amounts must not be zero while supplying liquidity";
|
|
77
|
-
readonly 6019: "Liquidity insufficient";
|
|
78
|
-
readonly 6020: "Transaction too old";
|
|
79
|
-
readonly 6021: "Price slippage check failed";
|
|
80
|
-
readonly 6022: "Too little output received";
|
|
81
|
-
readonly 6023: "Too much input paid";
|
|
82
|
-
readonly 6024: "Swap amount cannot be zero";
|
|
83
|
-
readonly 6025: "Input pool vault is invalid";
|
|
84
|
-
readonly 6026: "Swap input or output amount is too small";
|
|
85
|
-
readonly 6027: "Not enough tick array accounts";
|
|
86
|
-
readonly 6028: "Invalid first tick array account";
|
|
87
|
-
readonly 6029: "Invalid reward index";
|
|
88
|
-
readonly 6030: "Reward token limit reached";
|
|
89
|
-
readonly 6031: "Reward token already in use";
|
|
90
|
-
readonly 6032: "Reward tokens must contain one of pool vault mints";
|
|
91
|
-
readonly 6033: "Invalid reward init param";
|
|
92
|
-
readonly 6034: "Invalid collect reward desired amount";
|
|
93
|
-
readonly 6035: "Invalid collect reward input account number";
|
|
94
|
-
readonly 6036: "Invalid reward period";
|
|
95
|
-
readonly 6037: "Reward emissions modification only allowed within 72 hours of cycle end";
|
|
96
|
-
readonly 6038: "Uninitialized reward info";
|
|
97
|
-
readonly 6039: "Token2022 mint extension not supported";
|
|
98
|
-
readonly 6040: "Missing tick array bitmap extension account";
|
|
99
|
-
readonly 6041: "Insufficient liquidity for this direction";
|
|
100
|
-
readonly 6042: "Max token overflow";
|
|
101
|
-
readonly 6043: "Calculate overflow";
|
|
102
|
-
readonly 6044: "Transfer fee calculation mismatch";
|
|
103
|
-
};
|
|
104
|
-
export declare const DISCRIMINATORS: {
|
|
105
|
-
readonly POOL_STATE: Uint8Array<ArrayBuffer>;
|
|
106
|
-
readonly AMM_CONFIG: Uint8Array<ArrayBuffer>;
|
|
107
|
-
readonly POSITION_STATE: Uint8Array<ArrayBuffer>;
|
|
108
|
-
readonly TICK_ARRAY_STATE: Uint8Array<ArrayBuffer>;
|
|
109
|
-
readonly OBSERVATION_STATE: Uint8Array<ArrayBuffer>;
|
|
110
|
-
};
|
|
111
47
|
export declare const PDA_SEEDS: {
|
|
112
48
|
readonly AMM_CONFIG: "amm_config";
|
|
113
49
|
readonly POOL_STATE: "pool";
|
|
@@ -119,4 +55,8 @@ export declare const PDA_SEEDS: {
|
|
|
119
55
|
readonly OPERATION: "operation";
|
|
120
56
|
readonly BITMAP_EXTENSION: "pool_tick_array_bitmap_extension";
|
|
121
57
|
};
|
|
58
|
+
export declare const API_ENDPONTS: {
|
|
59
|
+
mainnet: string;
|
|
60
|
+
devnet: string;
|
|
61
|
+
};
|
|
122
62
|
//# sourceMappingURL=constants.d.ts.map
|
package/lib/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,OAAO,CAAC;AAIvB,eAAO,MAAM,uBAAuB,EACgB,OAAO,CAAC;AAG5D,eAAO,MAAM,mBAAmB,EACmB,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAG1G,eAAO,MAAM,iBAAiB,EACU,OAAO,CAAC,kCAAkC,CAAC,CAAC;AACpF,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,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AMM_V3_PROGRAM_ADDRESS: () => AMM_V3_PROGRAM_ADDRESS,
|
|
34
|
+
API_ENDPONTS: () => API_ENDPONTS,
|
|
34
35
|
BIT_PRECISION: () => BIT_PRECISION,
|
|
35
36
|
Clmm: () => Clmm,
|
|
36
37
|
ClmmSdk: () => ClmmSdk,
|
|
37
|
-
DEFAULT_COMPUTE_UNITS: () => DEFAULT_COMPUTE_UNITS,
|
|
38
38
|
DEFAULT_CONFIG: () => DEFAULT_CONFIG,
|
|
39
39
|
DEFAULT_DEADLINE_SECONDS: () => DEFAULT_DEADLINE_SECONDS,
|
|
40
40
|
DEFAULT_SDK_CONFIG: () => DEFAULT_SDK_CONFIG,
|
|
41
41
|
DEFAULT_SLIPPAGE_TOLERANCE: () => DEFAULT_SLIPPAGE_TOLERANCE,
|
|
42
|
-
DISCRIMINATORS: () => DISCRIMINATORS,
|
|
43
|
-
ERROR_MESSAGES: () => ERROR_MESSAGES,
|
|
44
|
-
FEE_PRECISION: () => FEE_PRECISION,
|
|
45
42
|
FEE_RATE_DENOMINATOR: () => FEE_RATE_DENOMINATOR,
|
|
46
43
|
FEE_TIERS: () => FEE_TIERS,
|
|
47
|
-
LIQUIDITY_PRECISION: () => LIQUIDITY_PRECISION,
|
|
48
44
|
LOG_B_2_X32: () => LOG_B_2_X32,
|
|
49
45
|
LOG_B_P_ERR_MARGIN_LOWER_X64: () => LOG_B_P_ERR_MARGIN_LOWER_X64,
|
|
50
46
|
LOG_B_P_ERR_MARGIN_UPPER_X64: () => LOG_B_P_ERR_MARGIN_UPPER_X64,
|
|
@@ -62,8 +58,6 @@ __export(index_exports, {
|
|
|
62
58
|
NEGATIVE_ONE: () => NEGATIVE_ONE,
|
|
63
59
|
ONE: () => ONE,
|
|
64
60
|
PDA_SEEDS: () => PDA_SEEDS,
|
|
65
|
-
PRICE_PRECISION: () => PRICE_PRECISION,
|
|
66
|
-
PRIORITY_FEE_MICRO_LAMPORTS: () => PRIORITY_FEE_MICRO_LAMPORTS,
|
|
67
61
|
PdaUtils: () => PdaUtils,
|
|
68
62
|
PoolManager: () => PoolManager,
|
|
69
63
|
PoolUtils: () => PoolUtils,
|
|
@@ -81,7 +75,6 @@ __export(index_exports, {
|
|
|
81
75
|
TickMath: () => TickMath,
|
|
82
76
|
TickUtils: () => TickUtils,
|
|
83
77
|
U64Resolution: () => U64Resolution,
|
|
84
|
-
WELL_KNOWN_TOKENS: () => WELL_KNOWN_TOKENS,
|
|
85
78
|
ZERO: () => ZERO,
|
|
86
79
|
addresstoBytes: () => addresstoBytes,
|
|
87
80
|
approximatelyEqual: () => approximatelyEqual,
|
|
@@ -97,6 +90,7 @@ __export(index_exports, {
|
|
|
97
90
|
formatAmount: () => formatAmount,
|
|
98
91
|
generated: () => generated_exports,
|
|
99
92
|
getAmmV3ErrorMessage: () => getAmmV3ErrorMessage,
|
|
93
|
+
getApisFromEndpoint: () => getApisFromEndpoint,
|
|
100
94
|
getClosePositionInstruction: () => getClosePositionInstruction,
|
|
101
95
|
getCreateAmmConfigInstruction: () => getCreateAmmConfigInstruction,
|
|
102
96
|
getCreatePoolInstruction: () => getCreatePoolInstruction,
|
|
@@ -6392,71 +6386,6 @@ var DEFAULT_CONFIG = {
|
|
|
6392
6386
|
// 1 second
|
|
6393
6387
|
};
|
|
6394
6388
|
var TICKS_PER_ARRAY = 60;
|
|
6395
|
-
var PRICE_PRECISION = 1e6;
|
|
6396
|
-
var LIQUIDITY_PRECISION = 1e12;
|
|
6397
|
-
var FEE_PRECISION = 1e6;
|
|
6398
|
-
var DEFAULT_COMPUTE_UNITS = 4e5;
|
|
6399
|
-
var PRIORITY_FEE_MICRO_LAMPORTS = 1e3;
|
|
6400
|
-
var WELL_KNOWN_TOKENS = {
|
|
6401
|
-
SOL: "So11111111111111111111111111111111111111112",
|
|
6402
|
-
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
6403
|
-
USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
|
|
6404
|
-
// Add more as needed
|
|
6405
|
-
};
|
|
6406
|
-
var ERROR_MESSAGES = {
|
|
6407
|
-
6e3: "LOK error",
|
|
6408
|
-
6001: "Not approved",
|
|
6409
|
-
6002: "Invalid update config flag",
|
|
6410
|
-
6003: "Account lack",
|
|
6411
|
-
6004: "Must collect fees and rewards before closing position",
|
|
6412
|
-
6005: "Minting amount should be greater than 0",
|
|
6413
|
-
6006: "Tick out of range",
|
|
6414
|
-
6007: "Lower tick must be below upper tick",
|
|
6415
|
-
6008: "Tick must be >= minimum tick (-443636)",
|
|
6416
|
-
6009: "Tick must be <= maximum tick (443636)",
|
|
6417
|
-
6010: "Tick must be divisible by tick spacing",
|
|
6418
|
-
6011: "Invalid tick array account",
|
|
6419
|
-
6012: "Invalid tick array boundary",
|
|
6420
|
-
6013: "Square root price limit overflow",
|
|
6421
|
-
6014: "sqrt_price_x64 out of range",
|
|
6422
|
-
6015: "Liquidity sub delta L must be smaller than before",
|
|
6423
|
-
6016: "Liquidity add delta L must be >= before",
|
|
6424
|
-
6017: "Invalid liquidity when updating position",
|
|
6425
|
-
6018: "Both token amounts must not be zero while supplying liquidity",
|
|
6426
|
-
6019: "Liquidity insufficient",
|
|
6427
|
-
6020: "Transaction too old",
|
|
6428
|
-
6021: "Price slippage check failed",
|
|
6429
|
-
6022: "Too little output received",
|
|
6430
|
-
6023: "Too much input paid",
|
|
6431
|
-
6024: "Swap amount cannot be zero",
|
|
6432
|
-
6025: "Input pool vault is invalid",
|
|
6433
|
-
6026: "Swap input or output amount is too small",
|
|
6434
|
-
6027: "Not enough tick array accounts",
|
|
6435
|
-
6028: "Invalid first tick array account",
|
|
6436
|
-
6029: "Invalid reward index",
|
|
6437
|
-
6030: "Reward token limit reached",
|
|
6438
|
-
6031: "Reward token already in use",
|
|
6439
|
-
6032: "Reward tokens must contain one of pool vault mints",
|
|
6440
|
-
6033: "Invalid reward init param",
|
|
6441
|
-
6034: "Invalid collect reward desired amount",
|
|
6442
|
-
6035: "Invalid collect reward input account number",
|
|
6443
|
-
6036: "Invalid reward period",
|
|
6444
|
-
6037: "Reward emissions modification only allowed within 72 hours of cycle end",
|
|
6445
|
-
6038: "Uninitialized reward info",
|
|
6446
|
-
6039: "Token2022 mint extension not supported",
|
|
6447
|
-
6040: "Missing tick array bitmap extension account",
|
|
6448
|
-
6041: "Insufficient liquidity for this direction",
|
|
6449
|
-
6042: "Max token overflow",
|
|
6450
|
-
6043: "Calculate overflow",
|
|
6451
|
-
6044: "Transfer fee calculation mismatch"
|
|
6452
|
-
};
|
|
6453
|
-
var DISCRIMINATORS = {
|
|
6454
|
-
POOL_STATE: new Uint8Array([247, 237, 227, 245, 215, 195, 222, 70]),
|
|
6455
|
-
AMM_CONFIG: new Uint8Array([218, 244, 33, 104, 203, 203, 43, 111]),
|
|
6456
|
-
POSITION_STATE: new Uint8Array([70, 111, 150, 126, 230, 15, 25, 117]),
|
|
6457
|
-
TICK_ARRAY_STATE: new Uint8Array([192, 155, 85, 205, 49, 249, 129, 42]),
|
|
6458
|
-
OBSERVATION_STATE: new Uint8Array([122, 174, 197, 53, 129, 9, 165, 132])
|
|
6459
|
-
};
|
|
6460
6389
|
var PDA_SEEDS = {
|
|
6461
6390
|
AMM_CONFIG: "amm_config",
|
|
6462
6391
|
POOL_STATE: "pool",
|
|
@@ -6468,6 +6397,12 @@ var PDA_SEEDS = {
|
|
|
6468
6397
|
OPERATION: "operation",
|
|
6469
6398
|
BITMAP_EXTENSION: "pool_tick_array_bitmap_extension"
|
|
6470
6399
|
};
|
|
6400
|
+
var STABBLE_CLMM_API_DEVNET = "https://dev-mclmm-api.stabble.org";
|
|
6401
|
+
var STABBLE_CLMM_API_MAINNET = "https://mclmm-api.stabble.org";
|
|
6402
|
+
var API_ENDPONTS = {
|
|
6403
|
+
mainnet: STABBLE_CLMM_API_MAINNET,
|
|
6404
|
+
devnet: STABBLE_CLMM_API_DEVNET
|
|
6405
|
+
};
|
|
6471
6406
|
|
|
6472
6407
|
// src/utils/math.ts
|
|
6473
6408
|
var MathUtils = class {
|
|
@@ -8234,6 +8169,12 @@ function getFakeSigner(address4) {
|
|
|
8234
8169
|
}
|
|
8235
8170
|
};
|
|
8236
8171
|
}
|
|
8172
|
+
function getApisFromEndpoint(rpc) {
|
|
8173
|
+
if ("requestAirdrop" in rpc) {
|
|
8174
|
+
return API_ENDPONTS.devnet;
|
|
8175
|
+
}
|
|
8176
|
+
return API_ENDPONTS.mainnet;
|
|
8177
|
+
}
|
|
8237
8178
|
|
|
8238
8179
|
// src/clmm.ts
|
|
8239
8180
|
var Clmm = class {
|
|
@@ -8605,12 +8546,11 @@ var PositionManager = class {
|
|
|
8605
8546
|
tickLower,
|
|
8606
8547
|
tickUpper
|
|
8607
8548
|
);
|
|
8608
|
-
const instruction = await
|
|
8549
|
+
const instruction = await getOpenPositionWithToken22NftInstructionAsync({
|
|
8609
8550
|
payer: ownerInfo.feePayer,
|
|
8610
8551
|
positionNftOwner: ownerInfo.wallet,
|
|
8611
8552
|
positionNftMint: nftMintAccount,
|
|
8612
8553
|
positionNftAccount: positionNftAccountPda,
|
|
8613
|
-
metadataAccount: metadataPda,
|
|
8614
8554
|
poolState: poolAccount.address,
|
|
8615
8555
|
protocolPosition: protocolPositionPda,
|
|
8616
8556
|
tokenAccount0: ownerInfo.tokenAccountA,
|
|
@@ -8629,6 +8569,30 @@ var PositionManager = class {
|
|
|
8629
8569
|
withMetadata,
|
|
8630
8570
|
baseFlag: null
|
|
8631
8571
|
});
|
|
8572
|
+
console.log({
|
|
8573
|
+
payer: ownerInfo.feePayer,
|
|
8574
|
+
positionNftOwner: ownerInfo.wallet,
|
|
8575
|
+
positionNftMint: nftMintAccount,
|
|
8576
|
+
positionNftAccount: positionNftAccountPda,
|
|
8577
|
+
poolState: poolAccount.address,
|
|
8578
|
+
protocolPosition: protocolPositionPda,
|
|
8579
|
+
tokenAccount0: ownerInfo.tokenAccountA,
|
|
8580
|
+
tokenAccount1: ownerInfo.tokenAccountB,
|
|
8581
|
+
tokenVault0: poolAccount.data.tokenVault0,
|
|
8582
|
+
tokenVault1: poolAccount.data.tokenVault1,
|
|
8583
|
+
vault0Mint: poolAccount.data.tokenMint0,
|
|
8584
|
+
vault1Mint: poolAccount.data.tokenMint0,
|
|
8585
|
+
tickLowerIndex: tickLower,
|
|
8586
|
+
tickUpperIndex: tickUpper,
|
|
8587
|
+
tickArrayLowerStartIndex,
|
|
8588
|
+
tickArrayUpperStartIndex,
|
|
8589
|
+
liquidity,
|
|
8590
|
+
amount0Max: amountMaxA,
|
|
8591
|
+
amount1Max: amountMaxB,
|
|
8592
|
+
withMetadata,
|
|
8593
|
+
baseFlag: null
|
|
8594
|
+
});
|
|
8595
|
+
console.log(instruction.accounts);
|
|
8632
8596
|
return {
|
|
8633
8597
|
instructions: [instruction],
|
|
8634
8598
|
signers,
|
|
@@ -8701,12 +8665,11 @@ var PositionManager = class {
|
|
|
8701
8665
|
);
|
|
8702
8666
|
const amount0Max = base === "MintA" ? baseAmount : otherAmountMax;
|
|
8703
8667
|
const amount1Max = base === "MintA" ? otherAmountMax : baseAmount;
|
|
8704
|
-
const instruction = await
|
|
8668
|
+
const instruction = await getOpenPositionWithToken22NftInstructionAsync({
|
|
8705
8669
|
payer: ownerInfo.wallet,
|
|
8706
8670
|
positionNftOwner: ownerInfo.wallet.address,
|
|
8707
8671
|
positionNftMint: nftMintAccount,
|
|
8708
8672
|
positionNftAccount: positionNftAccountPda,
|
|
8709
|
-
metadataAccount: metadataPda,
|
|
8710
8673
|
poolState: poolAccount.address,
|
|
8711
8674
|
protocolPosition: protocolPositionPda,
|
|
8712
8675
|
tokenAccount0: ownerInfo.tokenAccountA,
|
|
@@ -9082,17 +9045,83 @@ var PositionManager = class {
|
|
|
9082
9045
|
}
|
|
9083
9046
|
};
|
|
9084
9047
|
|
|
9085
|
-
// src/api/
|
|
9048
|
+
// src/api/config.ts
|
|
9086
9049
|
var import_axios = __toESM(require("axios"));
|
|
9087
|
-
var
|
|
9050
|
+
var ClmmConfigApi = class {
|
|
9088
9051
|
constructor(config) {
|
|
9089
9052
|
this.config = config;
|
|
9090
9053
|
this.client = import_axios.default.create({
|
|
9091
9054
|
baseURL: this.config.baseUrl,
|
|
9092
9055
|
timeout: this.config.timeout ?? 1e4,
|
|
9093
9056
|
headers: {
|
|
9094
|
-
"Content-Type": "application/json"
|
|
9095
|
-
|
|
9057
|
+
"Content-Type": "application/json"
|
|
9058
|
+
}
|
|
9059
|
+
});
|
|
9060
|
+
}
|
|
9061
|
+
client;
|
|
9062
|
+
/**
|
|
9063
|
+
* Fetch all configs
|
|
9064
|
+
* @returns CLMM config information or null if not found
|
|
9065
|
+
*/
|
|
9066
|
+
async getClmmConfigs() {
|
|
9067
|
+
try {
|
|
9068
|
+
const response = await this.client.get("/clmm-configs");
|
|
9069
|
+
return response.data;
|
|
9070
|
+
} catch (error) {
|
|
9071
|
+
if (this.isNotFoundError(error)) return null;
|
|
9072
|
+
throw this.handleApiError(error);
|
|
9073
|
+
}
|
|
9074
|
+
}
|
|
9075
|
+
/**
|
|
9076
|
+
* Handle API errors and convert to Error
|
|
9077
|
+
* @param error - Error from axios
|
|
9078
|
+
* @returns Error with appropriate message
|
|
9079
|
+
*/
|
|
9080
|
+
handleApiError(error) {
|
|
9081
|
+
if (import_axios.default.isAxiosError(error)) {
|
|
9082
|
+
const axiosError = error;
|
|
9083
|
+
if (axiosError.code === "ECONNABORTED") {
|
|
9084
|
+
return new Error("API request timeout");
|
|
9085
|
+
}
|
|
9086
|
+
if (axiosError.response) {
|
|
9087
|
+
const status = axiosError.response.status;
|
|
9088
|
+
const message = axiosError.response.data?.message || axiosError.message;
|
|
9089
|
+
if (status === 404) {
|
|
9090
|
+
return new Error(`CLMM config not found: ${message}`);
|
|
9091
|
+
}
|
|
9092
|
+
if (status >= 500) {
|
|
9093
|
+
return new Error(`API server error: ${message}`);
|
|
9094
|
+
}
|
|
9095
|
+
return new Error(`API request failed: ${message}`);
|
|
9096
|
+
}
|
|
9097
|
+
if (axiosError.request) {
|
|
9098
|
+
return new Error("No response from API server");
|
|
9099
|
+
}
|
|
9100
|
+
}
|
|
9101
|
+
return new Error(
|
|
9102
|
+
`Unknown API error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
9103
|
+
);
|
|
9104
|
+
}
|
|
9105
|
+
/**
|
|
9106
|
+
* Check if error is a 404 Not Found
|
|
9107
|
+
* @param error - Error to check
|
|
9108
|
+
* @returns True if 404 error
|
|
9109
|
+
*/
|
|
9110
|
+
isNotFoundError(error) {
|
|
9111
|
+
return import_axios.default.isAxiosError(error) && error.response?.status === 404;
|
|
9112
|
+
}
|
|
9113
|
+
};
|
|
9114
|
+
|
|
9115
|
+
// src/api/pools.ts
|
|
9116
|
+
var import_axios2 = __toESM(require("axios"));
|
|
9117
|
+
var PoolsApi = class {
|
|
9118
|
+
constructor(config) {
|
|
9119
|
+
this.config = config;
|
|
9120
|
+
this.client = import_axios2.default.create({
|
|
9121
|
+
baseURL: this.config.baseUrl,
|
|
9122
|
+
timeout: this.config.timeout ?? 1e4,
|
|
9123
|
+
headers: {
|
|
9124
|
+
"Content-Type": "application/json"
|
|
9096
9125
|
}
|
|
9097
9126
|
});
|
|
9098
9127
|
}
|
|
@@ -9107,7 +9136,7 @@ var PoolsApi = class {
|
|
|
9107
9136
|
const response = await this.client.get(
|
|
9108
9137
|
`/pools/${poolAddress}`
|
|
9109
9138
|
);
|
|
9110
|
-
return
|
|
9139
|
+
return response.data.pool;
|
|
9111
9140
|
} catch (error) {
|
|
9112
9141
|
if (this.isNotFoundError(error)) return null;
|
|
9113
9142
|
throw this.handleApiError(error);
|
|
@@ -9120,7 +9149,7 @@ var PoolsApi = class {
|
|
|
9120
9149
|
async getAllPools() {
|
|
9121
9150
|
try {
|
|
9122
9151
|
const response = await this.client.get("/pools");
|
|
9123
|
-
return response.data
|
|
9152
|
+
return response.data;
|
|
9124
9153
|
} catch (error) {
|
|
9125
9154
|
throw this.handleApiError(error);
|
|
9126
9155
|
}
|
|
@@ -9139,81 +9168,19 @@ var PoolsApi = class {
|
|
|
9139
9168
|
tokenB
|
|
9140
9169
|
}
|
|
9141
9170
|
});
|
|
9142
|
-
return response.data
|
|
9171
|
+
return response.data;
|
|
9143
9172
|
} catch (error) {
|
|
9144
9173
|
if (this.isNotFoundError(error)) return [];
|
|
9145
9174
|
throw this.handleApiError(error);
|
|
9146
9175
|
}
|
|
9147
9176
|
}
|
|
9148
|
-
/**
|
|
9149
|
-
* Map API response to SDK PoolInfo type
|
|
9150
|
-
* @param apiPool - API pool response
|
|
9151
|
-
* @returns Transformed PoolInfo object
|
|
9152
|
-
*/
|
|
9153
|
-
mapApiResponseToPoolInfo(apiPool) {
|
|
9154
|
-
return {
|
|
9155
|
-
discriminator: new Uint8Array(8),
|
|
9156
|
-
bump: new Uint8Array(1),
|
|
9157
|
-
ammConfig: apiPool.address,
|
|
9158
|
-
owner: apiPool.owner,
|
|
9159
|
-
tokenMint0: apiPool.tokenMint0,
|
|
9160
|
-
tokenMint1: apiPool.tokenMint1,
|
|
9161
|
-
tokenVault0: apiPool.tokenVault0,
|
|
9162
|
-
tokenVault1: apiPool.tokenVault1,
|
|
9163
|
-
observationKey: apiPool.address,
|
|
9164
|
-
mintDecimals0: 0,
|
|
9165
|
-
mintDecimals1: 0,
|
|
9166
|
-
tickSpacing: apiPool.tickSpacing,
|
|
9167
|
-
liquidity: BigInt(0),
|
|
9168
|
-
sqrtPriceX64: BigInt(apiPool.sqrtPriceX64),
|
|
9169
|
-
tickCurrent: apiPool.tick,
|
|
9170
|
-
padding3: 0,
|
|
9171
|
-
padding4: 0,
|
|
9172
|
-
feeGrowthGlobal0X64: BigInt(0),
|
|
9173
|
-
feeGrowthGlobal1X64: BigInt(0),
|
|
9174
|
-
protocolFeesToken0: BigInt(0),
|
|
9175
|
-
protocolFeesToken1: BigInt(0),
|
|
9176
|
-
swapInAmountToken0: BigInt(0),
|
|
9177
|
-
swapOutAmountToken1: BigInt(0),
|
|
9178
|
-
swapInAmountToken1: BigInt(0),
|
|
9179
|
-
swapOutAmountToken0: BigInt(0),
|
|
9180
|
-
status: 0,
|
|
9181
|
-
padding: new Uint8Array(7),
|
|
9182
|
-
rewardInfos: [],
|
|
9183
|
-
tickArrayBitmap: [],
|
|
9184
|
-
totalFeesToken0: BigInt(0),
|
|
9185
|
-
totalFeesClaimedToken0: BigInt(0),
|
|
9186
|
-
totalFeesToken1: BigInt(0),
|
|
9187
|
-
totalFeesClaimedToken1: BigInt(0),
|
|
9188
|
-
fundFeesToken0: BigInt(0),
|
|
9189
|
-
fundFeesToken1: BigInt(0),
|
|
9190
|
-
openTime: BigInt(0),
|
|
9191
|
-
recentEpoch: BigInt(0),
|
|
9192
|
-
padding1: [],
|
|
9193
|
-
padding2: [],
|
|
9194
|
-
currentPrice: 0,
|
|
9195
|
-
tokenA: {
|
|
9196
|
-
mint: apiPool.tokenMint0,
|
|
9197
|
-
symbol: "TOKEN_A",
|
|
9198
|
-
decimals: 0
|
|
9199
|
-
},
|
|
9200
|
-
tokenB: {
|
|
9201
|
-
mint: apiPool.tokenMint1,
|
|
9202
|
-
symbol: "TOKEN_B",
|
|
9203
|
-
decimals: 0
|
|
9204
|
-
},
|
|
9205
|
-
tvl: void 0,
|
|
9206
|
-
volume24h: void 0,
|
|
9207
|
-
apy: void 0
|
|
9208
|
-
};
|
|
9209
|
-
}
|
|
9210
9177
|
/**
|
|
9211
9178
|
* Handle API errors and convert to Error
|
|
9212
9179
|
* @param error - Error from axios
|
|
9213
9180
|
* @returns Error with appropriate message
|
|
9214
9181
|
*/
|
|
9215
9182
|
handleApiError(error) {
|
|
9216
|
-
if (
|
|
9183
|
+
if (import_axios2.default.isAxiosError(error)) {
|
|
9217
9184
|
const axiosError = error;
|
|
9218
9185
|
if (axiosError.code === "ECONNABORTED") {
|
|
9219
9186
|
return new Error("API request timeout");
|
|
@@ -9243,7 +9210,7 @@ var PoolsApi = class {
|
|
|
9243
9210
|
* @returns True if 404 error
|
|
9244
9211
|
*/
|
|
9245
9212
|
isNotFoundError(error) {
|
|
9246
|
-
return
|
|
9213
|
+
return import_axios2.default.isAxiosError(error) && error.response?.status === 404;
|
|
9247
9214
|
}
|
|
9248
9215
|
};
|
|
9249
9216
|
|
|
@@ -9252,8 +9219,10 @@ var ClmmApi = class {
|
|
|
9252
9219
|
constructor(config) {
|
|
9253
9220
|
this.config = config;
|
|
9254
9221
|
this.pools = new PoolsApi(this.config);
|
|
9222
|
+
this.clmmConfig = new ClmmConfigApi(this.config);
|
|
9255
9223
|
}
|
|
9256
9224
|
pools;
|
|
9225
|
+
clmmConfig;
|
|
9257
9226
|
};
|
|
9258
9227
|
|
|
9259
9228
|
// src/client.ts
|
|
@@ -9275,7 +9244,9 @@ var ClmmSdk = class _ClmmSdk {
|
|
|
9275
9244
|
constructor(config) {
|
|
9276
9245
|
this.config = config;
|
|
9277
9246
|
this.clmm = new Clmm(config);
|
|
9278
|
-
|
|
9247
|
+
const baseUrl = getApisFromEndpoint(config.rpc);
|
|
9248
|
+
const apiConfig = config.apiConfig ? config.apiConfig : { baseUrl };
|
|
9249
|
+
this.api = new ClmmApi(apiConfig);
|
|
9279
9250
|
this.pools = new PoolManager(config);
|
|
9280
9251
|
this.positions = new PositionManager(config);
|
|
9281
9252
|
}
|
|
@@ -9317,20 +9288,16 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9317
9288
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9318
9289
|
0 && (module.exports = {
|
|
9319
9290
|
AMM_V3_PROGRAM_ADDRESS,
|
|
9291
|
+
API_ENDPONTS,
|
|
9320
9292
|
BIT_PRECISION,
|
|
9321
9293
|
Clmm,
|
|
9322
9294
|
ClmmSdk,
|
|
9323
|
-
DEFAULT_COMPUTE_UNITS,
|
|
9324
9295
|
DEFAULT_CONFIG,
|
|
9325
9296
|
DEFAULT_DEADLINE_SECONDS,
|
|
9326
9297
|
DEFAULT_SDK_CONFIG,
|
|
9327
9298
|
DEFAULT_SLIPPAGE_TOLERANCE,
|
|
9328
|
-
DISCRIMINATORS,
|
|
9329
|
-
ERROR_MESSAGES,
|
|
9330
|
-
FEE_PRECISION,
|
|
9331
9299
|
FEE_RATE_DENOMINATOR,
|
|
9332
9300
|
FEE_TIERS,
|
|
9333
|
-
LIQUIDITY_PRECISION,
|
|
9334
9301
|
LOG_B_2_X32,
|
|
9335
9302
|
LOG_B_P_ERR_MARGIN_LOWER_X64,
|
|
9336
9303
|
LOG_B_P_ERR_MARGIN_UPPER_X64,
|
|
@@ -9348,8 +9315,6 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9348
9315
|
NEGATIVE_ONE,
|
|
9349
9316
|
ONE,
|
|
9350
9317
|
PDA_SEEDS,
|
|
9351
|
-
PRICE_PRECISION,
|
|
9352
|
-
PRIORITY_FEE_MICRO_LAMPORTS,
|
|
9353
9318
|
PdaUtils,
|
|
9354
9319
|
PoolManager,
|
|
9355
9320
|
PoolUtils,
|
|
@@ -9367,7 +9332,6 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9367
9332
|
TickMath,
|
|
9368
9333
|
TickUtils,
|
|
9369
9334
|
U64Resolution,
|
|
9370
|
-
WELL_KNOWN_TOKENS,
|
|
9371
9335
|
ZERO,
|
|
9372
9336
|
addresstoBytes,
|
|
9373
9337
|
approximatelyEqual,
|
|
@@ -9383,6 +9347,7 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9383
9347
|
formatAmount,
|
|
9384
9348
|
generated,
|
|
9385
9349
|
getAmmV3ErrorMessage,
|
|
9350
|
+
getApisFromEndpoint,
|
|
9386
9351
|
getClosePositionInstruction,
|
|
9387
9352
|
getCreateAmmConfigInstruction,
|
|
9388
9353
|
getCreatePoolInstruction,
|
package/lib/index.mjs
CHANGED
|
@@ -7013,71 +7013,6 @@ var DEFAULT_CONFIG = {
|
|
|
7013
7013
|
// 1 second
|
|
7014
7014
|
};
|
|
7015
7015
|
var TICKS_PER_ARRAY = 60;
|
|
7016
|
-
var PRICE_PRECISION = 1e6;
|
|
7017
|
-
var LIQUIDITY_PRECISION = 1e12;
|
|
7018
|
-
var FEE_PRECISION = 1e6;
|
|
7019
|
-
var DEFAULT_COMPUTE_UNITS = 4e5;
|
|
7020
|
-
var PRIORITY_FEE_MICRO_LAMPORTS = 1e3;
|
|
7021
|
-
var WELL_KNOWN_TOKENS = {
|
|
7022
|
-
SOL: "So11111111111111111111111111111111111111112",
|
|
7023
|
-
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
7024
|
-
USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"
|
|
7025
|
-
// Add more as needed
|
|
7026
|
-
};
|
|
7027
|
-
var ERROR_MESSAGES = {
|
|
7028
|
-
6e3: "LOK error",
|
|
7029
|
-
6001: "Not approved",
|
|
7030
|
-
6002: "Invalid update config flag",
|
|
7031
|
-
6003: "Account lack",
|
|
7032
|
-
6004: "Must collect fees and rewards before closing position",
|
|
7033
|
-
6005: "Minting amount should be greater than 0",
|
|
7034
|
-
6006: "Tick out of range",
|
|
7035
|
-
6007: "Lower tick must be below upper tick",
|
|
7036
|
-
6008: "Tick must be >= minimum tick (-443636)",
|
|
7037
|
-
6009: "Tick must be <= maximum tick (443636)",
|
|
7038
|
-
6010: "Tick must be divisible by tick spacing",
|
|
7039
|
-
6011: "Invalid tick array account",
|
|
7040
|
-
6012: "Invalid tick array boundary",
|
|
7041
|
-
6013: "Square root price limit overflow",
|
|
7042
|
-
6014: "sqrt_price_x64 out of range",
|
|
7043
|
-
6015: "Liquidity sub delta L must be smaller than before",
|
|
7044
|
-
6016: "Liquidity add delta L must be >= before",
|
|
7045
|
-
6017: "Invalid liquidity when updating position",
|
|
7046
|
-
6018: "Both token amounts must not be zero while supplying liquidity",
|
|
7047
|
-
6019: "Liquidity insufficient",
|
|
7048
|
-
6020: "Transaction too old",
|
|
7049
|
-
6021: "Price slippage check failed",
|
|
7050
|
-
6022: "Too little output received",
|
|
7051
|
-
6023: "Too much input paid",
|
|
7052
|
-
6024: "Swap amount cannot be zero",
|
|
7053
|
-
6025: "Input pool vault is invalid",
|
|
7054
|
-
6026: "Swap input or output amount is too small",
|
|
7055
|
-
6027: "Not enough tick array accounts",
|
|
7056
|
-
6028: "Invalid first tick array account",
|
|
7057
|
-
6029: "Invalid reward index",
|
|
7058
|
-
6030: "Reward token limit reached",
|
|
7059
|
-
6031: "Reward token already in use",
|
|
7060
|
-
6032: "Reward tokens must contain one of pool vault mints",
|
|
7061
|
-
6033: "Invalid reward init param",
|
|
7062
|
-
6034: "Invalid collect reward desired amount",
|
|
7063
|
-
6035: "Invalid collect reward input account number",
|
|
7064
|
-
6036: "Invalid reward period",
|
|
7065
|
-
6037: "Reward emissions modification only allowed within 72 hours of cycle end",
|
|
7066
|
-
6038: "Uninitialized reward info",
|
|
7067
|
-
6039: "Token2022 mint extension not supported",
|
|
7068
|
-
6040: "Missing tick array bitmap extension account",
|
|
7069
|
-
6041: "Insufficient liquidity for this direction",
|
|
7070
|
-
6042: "Max token overflow",
|
|
7071
|
-
6043: "Calculate overflow",
|
|
7072
|
-
6044: "Transfer fee calculation mismatch"
|
|
7073
|
-
};
|
|
7074
|
-
var DISCRIMINATORS = {
|
|
7075
|
-
POOL_STATE: new Uint8Array([247, 237, 227, 245, 215, 195, 222, 70]),
|
|
7076
|
-
AMM_CONFIG: new Uint8Array([218, 244, 33, 104, 203, 203, 43, 111]),
|
|
7077
|
-
POSITION_STATE: new Uint8Array([70, 111, 150, 126, 230, 15, 25, 117]),
|
|
7078
|
-
TICK_ARRAY_STATE: new Uint8Array([192, 155, 85, 205, 49, 249, 129, 42]),
|
|
7079
|
-
OBSERVATION_STATE: new Uint8Array([122, 174, 197, 53, 129, 9, 165, 132])
|
|
7080
|
-
};
|
|
7081
7016
|
var PDA_SEEDS = {
|
|
7082
7017
|
AMM_CONFIG: "amm_config",
|
|
7083
7018
|
POOL_STATE: "pool",
|
|
@@ -7089,6 +7024,12 @@ var PDA_SEEDS = {
|
|
|
7089
7024
|
OPERATION: "operation",
|
|
7090
7025
|
BITMAP_EXTENSION: "pool_tick_array_bitmap_extension"
|
|
7091
7026
|
};
|
|
7027
|
+
var STABBLE_CLMM_API_DEVNET = "https://dev-mclmm-api.stabble.org";
|
|
7028
|
+
var STABBLE_CLMM_API_MAINNET = "https://mclmm-api.stabble.org";
|
|
7029
|
+
var API_ENDPONTS = {
|
|
7030
|
+
mainnet: STABBLE_CLMM_API_MAINNET,
|
|
7031
|
+
devnet: STABBLE_CLMM_API_DEVNET
|
|
7032
|
+
};
|
|
7092
7033
|
|
|
7093
7034
|
// src/utils/math.ts
|
|
7094
7035
|
var MathUtils = class {
|
|
@@ -8777,7 +8718,9 @@ var PoolUtils = class {
|
|
|
8777
8718
|
};
|
|
8778
8719
|
|
|
8779
8720
|
// src/utils/index.ts
|
|
8780
|
-
import {
|
|
8721
|
+
import {
|
|
8722
|
+
getAddressEncoder as getAddressEncoder30
|
|
8723
|
+
} from "@solana/kit";
|
|
8781
8724
|
function validateAddress(address4, name = "address") {
|
|
8782
8725
|
if (!address4 || address4.length === 0) {
|
|
8783
8726
|
throw new ClmmError(
|
|
@@ -8862,6 +8805,12 @@ function getFakeSigner(address4) {
|
|
|
8862
8805
|
}
|
|
8863
8806
|
};
|
|
8864
8807
|
}
|
|
8808
|
+
function getApisFromEndpoint(rpc) {
|
|
8809
|
+
if ("requestAirdrop" in rpc) {
|
|
8810
|
+
return API_ENDPONTS.devnet;
|
|
8811
|
+
}
|
|
8812
|
+
return API_ENDPONTS.mainnet;
|
|
8813
|
+
}
|
|
8865
8814
|
|
|
8866
8815
|
// src/clmm.ts
|
|
8867
8816
|
var Clmm = class {
|
|
@@ -9178,13 +9127,8 @@ var PoolManager = class {
|
|
|
9178
9127
|
};
|
|
9179
9128
|
|
|
9180
9129
|
// src/position-manager.ts
|
|
9181
|
-
import {
|
|
9182
|
-
|
|
9183
|
-
} from "@solana/kit";
|
|
9184
|
-
import {
|
|
9185
|
-
TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS2,
|
|
9186
|
-
findAssociatedTokenPda
|
|
9187
|
-
} from "@solana-program/token";
|
|
9130
|
+
import { generateKeyPairSigner } from "@solana/kit";
|
|
9131
|
+
import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS2 } from "@solana-program/token";
|
|
9188
9132
|
import { TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
|
|
9189
9133
|
import BN6 from "bn.js";
|
|
9190
9134
|
var PositionManager = class {
|
|
@@ -9240,12 +9184,11 @@ var PositionManager = class {
|
|
|
9240
9184
|
tickLower,
|
|
9241
9185
|
tickUpper
|
|
9242
9186
|
);
|
|
9243
|
-
const instruction = await
|
|
9187
|
+
const instruction = await getOpenPositionWithToken22NftInstructionAsync({
|
|
9244
9188
|
payer: ownerInfo.feePayer,
|
|
9245
9189
|
positionNftOwner: ownerInfo.wallet,
|
|
9246
9190
|
positionNftMint: nftMintAccount,
|
|
9247
9191
|
positionNftAccount: positionNftAccountPda,
|
|
9248
|
-
metadataAccount: metadataPda,
|
|
9249
9192
|
poolState: poolAccount.address,
|
|
9250
9193
|
protocolPosition: protocolPositionPda,
|
|
9251
9194
|
tokenAccount0: ownerInfo.tokenAccountA,
|
|
@@ -9264,6 +9207,30 @@ var PositionManager = class {
|
|
|
9264
9207
|
withMetadata,
|
|
9265
9208
|
baseFlag: null
|
|
9266
9209
|
});
|
|
9210
|
+
console.log({
|
|
9211
|
+
payer: ownerInfo.feePayer,
|
|
9212
|
+
positionNftOwner: ownerInfo.wallet,
|
|
9213
|
+
positionNftMint: nftMintAccount,
|
|
9214
|
+
positionNftAccount: positionNftAccountPda,
|
|
9215
|
+
poolState: poolAccount.address,
|
|
9216
|
+
protocolPosition: protocolPositionPda,
|
|
9217
|
+
tokenAccount0: ownerInfo.tokenAccountA,
|
|
9218
|
+
tokenAccount1: ownerInfo.tokenAccountB,
|
|
9219
|
+
tokenVault0: poolAccount.data.tokenVault0,
|
|
9220
|
+
tokenVault1: poolAccount.data.tokenVault1,
|
|
9221
|
+
vault0Mint: poolAccount.data.tokenMint0,
|
|
9222
|
+
vault1Mint: poolAccount.data.tokenMint0,
|
|
9223
|
+
tickLowerIndex: tickLower,
|
|
9224
|
+
tickUpperIndex: tickUpper,
|
|
9225
|
+
tickArrayLowerStartIndex,
|
|
9226
|
+
tickArrayUpperStartIndex,
|
|
9227
|
+
liquidity,
|
|
9228
|
+
amount0Max: amountMaxA,
|
|
9229
|
+
amount1Max: amountMaxB,
|
|
9230
|
+
withMetadata,
|
|
9231
|
+
baseFlag: null
|
|
9232
|
+
});
|
|
9233
|
+
console.log(instruction.accounts);
|
|
9267
9234
|
return {
|
|
9268
9235
|
instructions: [instruction],
|
|
9269
9236
|
signers,
|
|
@@ -9336,12 +9303,11 @@ var PositionManager = class {
|
|
|
9336
9303
|
);
|
|
9337
9304
|
const amount0Max = base === "MintA" ? baseAmount : otherAmountMax;
|
|
9338
9305
|
const amount1Max = base === "MintA" ? otherAmountMax : baseAmount;
|
|
9339
|
-
const instruction = await
|
|
9306
|
+
const instruction = await getOpenPositionWithToken22NftInstructionAsync({
|
|
9340
9307
|
payer: ownerInfo.wallet,
|
|
9341
9308
|
positionNftOwner: ownerInfo.wallet.address,
|
|
9342
9309
|
positionNftMint: nftMintAccount,
|
|
9343
9310
|
positionNftAccount: positionNftAccountPda,
|
|
9344
|
-
metadataAccount: metadataPda,
|
|
9345
9311
|
poolState: poolAccount.address,
|
|
9346
9312
|
protocolPosition: protocolPositionPda,
|
|
9347
9313
|
tokenAccount0: ownerInfo.tokenAccountA,
|
|
@@ -9717,17 +9683,83 @@ var PositionManager = class {
|
|
|
9717
9683
|
}
|
|
9718
9684
|
};
|
|
9719
9685
|
|
|
9720
|
-
// src/api/
|
|
9686
|
+
// src/api/config.ts
|
|
9721
9687
|
import axios from "axios";
|
|
9722
|
-
var
|
|
9688
|
+
var ClmmConfigApi = class {
|
|
9723
9689
|
constructor(config) {
|
|
9724
9690
|
this.config = config;
|
|
9725
9691
|
this.client = axios.create({
|
|
9726
9692
|
baseURL: this.config.baseUrl,
|
|
9727
9693
|
timeout: this.config.timeout ?? 1e4,
|
|
9728
9694
|
headers: {
|
|
9729
|
-
"Content-Type": "application/json"
|
|
9730
|
-
|
|
9695
|
+
"Content-Type": "application/json"
|
|
9696
|
+
}
|
|
9697
|
+
});
|
|
9698
|
+
}
|
|
9699
|
+
client;
|
|
9700
|
+
/**
|
|
9701
|
+
* Fetch all configs
|
|
9702
|
+
* @returns CLMM config information or null if not found
|
|
9703
|
+
*/
|
|
9704
|
+
async getClmmConfigs() {
|
|
9705
|
+
try {
|
|
9706
|
+
const response = await this.client.get("/clmm-configs");
|
|
9707
|
+
return response.data;
|
|
9708
|
+
} catch (error) {
|
|
9709
|
+
if (this.isNotFoundError(error)) return null;
|
|
9710
|
+
throw this.handleApiError(error);
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9713
|
+
/**
|
|
9714
|
+
* Handle API errors and convert to Error
|
|
9715
|
+
* @param error - Error from axios
|
|
9716
|
+
* @returns Error with appropriate message
|
|
9717
|
+
*/
|
|
9718
|
+
handleApiError(error) {
|
|
9719
|
+
if (axios.isAxiosError(error)) {
|
|
9720
|
+
const axiosError = error;
|
|
9721
|
+
if (axiosError.code === "ECONNABORTED") {
|
|
9722
|
+
return new Error("API request timeout");
|
|
9723
|
+
}
|
|
9724
|
+
if (axiosError.response) {
|
|
9725
|
+
const status = axiosError.response.status;
|
|
9726
|
+
const message = axiosError.response.data?.message || axiosError.message;
|
|
9727
|
+
if (status === 404) {
|
|
9728
|
+
return new Error(`CLMM config not found: ${message}`);
|
|
9729
|
+
}
|
|
9730
|
+
if (status >= 500) {
|
|
9731
|
+
return new Error(`API server error: ${message}`);
|
|
9732
|
+
}
|
|
9733
|
+
return new Error(`API request failed: ${message}`);
|
|
9734
|
+
}
|
|
9735
|
+
if (axiosError.request) {
|
|
9736
|
+
return new Error("No response from API server");
|
|
9737
|
+
}
|
|
9738
|
+
}
|
|
9739
|
+
return new Error(
|
|
9740
|
+
`Unknown API error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
9741
|
+
);
|
|
9742
|
+
}
|
|
9743
|
+
/**
|
|
9744
|
+
* Check if error is a 404 Not Found
|
|
9745
|
+
* @param error - Error to check
|
|
9746
|
+
* @returns True if 404 error
|
|
9747
|
+
*/
|
|
9748
|
+
isNotFoundError(error) {
|
|
9749
|
+
return axios.isAxiosError(error) && error.response?.status === 404;
|
|
9750
|
+
}
|
|
9751
|
+
};
|
|
9752
|
+
|
|
9753
|
+
// src/api/pools.ts
|
|
9754
|
+
import axios2 from "axios";
|
|
9755
|
+
var PoolsApi = class {
|
|
9756
|
+
constructor(config) {
|
|
9757
|
+
this.config = config;
|
|
9758
|
+
this.client = axios2.create({
|
|
9759
|
+
baseURL: this.config.baseUrl,
|
|
9760
|
+
timeout: this.config.timeout ?? 1e4,
|
|
9761
|
+
headers: {
|
|
9762
|
+
"Content-Type": "application/json"
|
|
9731
9763
|
}
|
|
9732
9764
|
});
|
|
9733
9765
|
}
|
|
@@ -9742,7 +9774,7 @@ var PoolsApi = class {
|
|
|
9742
9774
|
const response = await this.client.get(
|
|
9743
9775
|
`/pools/${poolAddress}`
|
|
9744
9776
|
);
|
|
9745
|
-
return
|
|
9777
|
+
return response.data.pool;
|
|
9746
9778
|
} catch (error) {
|
|
9747
9779
|
if (this.isNotFoundError(error)) return null;
|
|
9748
9780
|
throw this.handleApiError(error);
|
|
@@ -9755,7 +9787,7 @@ var PoolsApi = class {
|
|
|
9755
9787
|
async getAllPools() {
|
|
9756
9788
|
try {
|
|
9757
9789
|
const response = await this.client.get("/pools");
|
|
9758
|
-
return response.data
|
|
9790
|
+
return response.data;
|
|
9759
9791
|
} catch (error) {
|
|
9760
9792
|
throw this.handleApiError(error);
|
|
9761
9793
|
}
|
|
@@ -9774,81 +9806,19 @@ var PoolsApi = class {
|
|
|
9774
9806
|
tokenB
|
|
9775
9807
|
}
|
|
9776
9808
|
});
|
|
9777
|
-
return response.data
|
|
9809
|
+
return response.data;
|
|
9778
9810
|
} catch (error) {
|
|
9779
9811
|
if (this.isNotFoundError(error)) return [];
|
|
9780
9812
|
throw this.handleApiError(error);
|
|
9781
9813
|
}
|
|
9782
9814
|
}
|
|
9783
|
-
/**
|
|
9784
|
-
* Map API response to SDK PoolInfo type
|
|
9785
|
-
* @param apiPool - API pool response
|
|
9786
|
-
* @returns Transformed PoolInfo object
|
|
9787
|
-
*/
|
|
9788
|
-
mapApiResponseToPoolInfo(apiPool) {
|
|
9789
|
-
return {
|
|
9790
|
-
discriminator: new Uint8Array(8),
|
|
9791
|
-
bump: new Uint8Array(1),
|
|
9792
|
-
ammConfig: apiPool.address,
|
|
9793
|
-
owner: apiPool.owner,
|
|
9794
|
-
tokenMint0: apiPool.tokenMint0,
|
|
9795
|
-
tokenMint1: apiPool.tokenMint1,
|
|
9796
|
-
tokenVault0: apiPool.tokenVault0,
|
|
9797
|
-
tokenVault1: apiPool.tokenVault1,
|
|
9798
|
-
observationKey: apiPool.address,
|
|
9799
|
-
mintDecimals0: 0,
|
|
9800
|
-
mintDecimals1: 0,
|
|
9801
|
-
tickSpacing: apiPool.tickSpacing,
|
|
9802
|
-
liquidity: BigInt(0),
|
|
9803
|
-
sqrtPriceX64: BigInt(apiPool.sqrtPriceX64),
|
|
9804
|
-
tickCurrent: apiPool.tick,
|
|
9805
|
-
padding3: 0,
|
|
9806
|
-
padding4: 0,
|
|
9807
|
-
feeGrowthGlobal0X64: BigInt(0),
|
|
9808
|
-
feeGrowthGlobal1X64: BigInt(0),
|
|
9809
|
-
protocolFeesToken0: BigInt(0),
|
|
9810
|
-
protocolFeesToken1: BigInt(0),
|
|
9811
|
-
swapInAmountToken0: BigInt(0),
|
|
9812
|
-
swapOutAmountToken1: BigInt(0),
|
|
9813
|
-
swapInAmountToken1: BigInt(0),
|
|
9814
|
-
swapOutAmountToken0: BigInt(0),
|
|
9815
|
-
status: 0,
|
|
9816
|
-
padding: new Uint8Array(7),
|
|
9817
|
-
rewardInfos: [],
|
|
9818
|
-
tickArrayBitmap: [],
|
|
9819
|
-
totalFeesToken0: BigInt(0),
|
|
9820
|
-
totalFeesClaimedToken0: BigInt(0),
|
|
9821
|
-
totalFeesToken1: BigInt(0),
|
|
9822
|
-
totalFeesClaimedToken1: BigInt(0),
|
|
9823
|
-
fundFeesToken0: BigInt(0),
|
|
9824
|
-
fundFeesToken1: BigInt(0),
|
|
9825
|
-
openTime: BigInt(0),
|
|
9826
|
-
recentEpoch: BigInt(0),
|
|
9827
|
-
padding1: [],
|
|
9828
|
-
padding2: [],
|
|
9829
|
-
currentPrice: 0,
|
|
9830
|
-
tokenA: {
|
|
9831
|
-
mint: apiPool.tokenMint0,
|
|
9832
|
-
symbol: "TOKEN_A",
|
|
9833
|
-
decimals: 0
|
|
9834
|
-
},
|
|
9835
|
-
tokenB: {
|
|
9836
|
-
mint: apiPool.tokenMint1,
|
|
9837
|
-
symbol: "TOKEN_B",
|
|
9838
|
-
decimals: 0
|
|
9839
|
-
},
|
|
9840
|
-
tvl: void 0,
|
|
9841
|
-
volume24h: void 0,
|
|
9842
|
-
apy: void 0
|
|
9843
|
-
};
|
|
9844
|
-
}
|
|
9845
9815
|
/**
|
|
9846
9816
|
* Handle API errors and convert to Error
|
|
9847
9817
|
* @param error - Error from axios
|
|
9848
9818
|
* @returns Error with appropriate message
|
|
9849
9819
|
*/
|
|
9850
9820
|
handleApiError(error) {
|
|
9851
|
-
if (
|
|
9821
|
+
if (axios2.isAxiosError(error)) {
|
|
9852
9822
|
const axiosError = error;
|
|
9853
9823
|
if (axiosError.code === "ECONNABORTED") {
|
|
9854
9824
|
return new Error("API request timeout");
|
|
@@ -9878,7 +9848,7 @@ var PoolsApi = class {
|
|
|
9878
9848
|
* @returns True if 404 error
|
|
9879
9849
|
*/
|
|
9880
9850
|
isNotFoundError(error) {
|
|
9881
|
-
return
|
|
9851
|
+
return axios2.isAxiosError(error) && error.response?.status === 404;
|
|
9882
9852
|
}
|
|
9883
9853
|
};
|
|
9884
9854
|
|
|
@@ -9887,8 +9857,10 @@ var ClmmApi = class {
|
|
|
9887
9857
|
constructor(config) {
|
|
9888
9858
|
this.config = config;
|
|
9889
9859
|
this.pools = new PoolsApi(this.config);
|
|
9860
|
+
this.clmmConfig = new ClmmConfigApi(this.config);
|
|
9890
9861
|
}
|
|
9891
9862
|
pools;
|
|
9863
|
+
clmmConfig;
|
|
9892
9864
|
};
|
|
9893
9865
|
|
|
9894
9866
|
// src/client.ts
|
|
@@ -9910,7 +9882,9 @@ var ClmmSdk = class _ClmmSdk {
|
|
|
9910
9882
|
constructor(config) {
|
|
9911
9883
|
this.config = config;
|
|
9912
9884
|
this.clmm = new Clmm(config);
|
|
9913
|
-
|
|
9885
|
+
const baseUrl = getApisFromEndpoint(config.rpc);
|
|
9886
|
+
const apiConfig = config.apiConfig ? config.apiConfig : { baseUrl };
|
|
9887
|
+
this.api = new ClmmApi(apiConfig);
|
|
9914
9888
|
this.pools = new PoolManager(config);
|
|
9915
9889
|
this.positions = new PositionManager(config);
|
|
9916
9890
|
}
|
|
@@ -9951,20 +9925,16 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9951
9925
|
};
|
|
9952
9926
|
export {
|
|
9953
9927
|
AMM_V3_PROGRAM_ADDRESS,
|
|
9928
|
+
API_ENDPONTS,
|
|
9954
9929
|
BIT_PRECISION,
|
|
9955
9930
|
Clmm,
|
|
9956
9931
|
ClmmSdk,
|
|
9957
|
-
DEFAULT_COMPUTE_UNITS,
|
|
9958
9932
|
DEFAULT_CONFIG,
|
|
9959
9933
|
DEFAULT_DEADLINE_SECONDS,
|
|
9960
9934
|
DEFAULT_SDK_CONFIG,
|
|
9961
9935
|
DEFAULT_SLIPPAGE_TOLERANCE,
|
|
9962
|
-
DISCRIMINATORS,
|
|
9963
|
-
ERROR_MESSAGES,
|
|
9964
|
-
FEE_PRECISION,
|
|
9965
9936
|
FEE_RATE_DENOMINATOR,
|
|
9966
9937
|
FEE_TIERS,
|
|
9967
|
-
LIQUIDITY_PRECISION,
|
|
9968
9938
|
LOG_B_2_X32,
|
|
9969
9939
|
LOG_B_P_ERR_MARGIN_LOWER_X64,
|
|
9970
9940
|
LOG_B_P_ERR_MARGIN_UPPER_X64,
|
|
@@ -9982,8 +9952,6 @@ export {
|
|
|
9982
9952
|
NEGATIVE_ONE,
|
|
9983
9953
|
ONE,
|
|
9984
9954
|
PDA_SEEDS,
|
|
9985
|
-
PRICE_PRECISION,
|
|
9986
|
-
PRIORITY_FEE_MICRO_LAMPORTS,
|
|
9987
9955
|
PdaUtils,
|
|
9988
9956
|
PoolManager,
|
|
9989
9957
|
PoolUtils,
|
|
@@ -10001,7 +9969,6 @@ export {
|
|
|
10001
9969
|
TickMath,
|
|
10002
9970
|
TickUtils,
|
|
10003
9971
|
U64Resolution,
|
|
10004
|
-
WELL_KNOWN_TOKENS,
|
|
10005
9972
|
ZERO,
|
|
10006
9973
|
addresstoBytes,
|
|
10007
9974
|
approximatelyEqual,
|
|
@@ -10017,6 +9984,7 @@ export {
|
|
|
10017
9984
|
formatAmount,
|
|
10018
9985
|
generated_exports as generated,
|
|
10019
9986
|
getAmmV3ErrorMessage,
|
|
9987
|
+
getApisFromEndpoint,
|
|
10020
9988
|
getClosePositionInstruction,
|
|
10021
9989
|
getCreateAmmConfigInstruction,
|
|
10022
9990
|
getCreatePoolInstruction,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Account, type Address, type TransactionSigner } from "@solana/kit";
|
|
2
2
|
import { PersonalPositionState, PoolState } from "./generated";
|
|
3
|
-
import type { ClmmSdkConfig,
|
|
3
|
+
import type { ClmmSdkConfig, MakeInstructionResult, PositionInfo } from "./types";
|
|
4
4
|
export declare class PositionManager {
|
|
5
5
|
private readonly config;
|
|
6
6
|
constructor(config: ClmmSdkConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position-manager.d.ts","sourceRoot":"","sources":["../src/position-manager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"position-manager.d.ts","sourceRoot":"","sources":["../src/position-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElG,OAAO,EAOL,qBAAqB,EACrB,SAAS,EACV,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAC,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQjF,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD;;;;;OAKG;IACG,yCAAyC,CAAC,MAAM,EAAE;QACtD,WAAW,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACzC,SAAS,EAAE;YACT,QAAQ,EAAE,iBAAiB,CAAC;YAC5B,MAAM,EAAE,OAAO,CAAC;YAChB,aAAa,EAAE,OAAO,CAAC;YACvB,aAAa,EAAE,OAAO,CAAC;YACvB,aAAa,CAAC,EAAE,OAAO,CAAC;SACzB,CAAC;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,mBAAmB,CAAC,EAAE,MAAM,iBAAiB,EAAE,CAAC;KACjD,GAAG,OAAO,CACT,qBAAqB,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;QACzB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,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,aAAa,EAAE,qBAAqB,CAAC;QACrC,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACvC,SAAS,EAAE;YACT,MAAM,EAAE,iBAAiB,CAAC;YAC1B,aAAa,EAAE,OAAO,CAAC;YACvB,aAAa,EAAE,OAAO,CAAC;SACxB,CAAC;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;IA8EtC;;;;OAIG;IACG,6BAA6B,CAAC,MAAM,EAAE;QAC1C,aAAa,EAAE,qBAAqB,CAAC;QACrC,SAAS,EAAE;YACT,MAAM,EAAE,iBAAiB,CAAC;SAC3B,CAAC;KACH,GAAG,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;IA6BtC;;;;OAIG;IACG,WAAW,CACf,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAuBxC;;;;;OAKG;IACH,kBAAkB,CAChB,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,EAAE,SAAS,GACd,YAAY;IA6Ff;;;;OAIG;IACG,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CA0EtE"}
|
package/lib/types.d.ts
CHANGED
|
@@ -3,26 +3,15 @@ import type { PoolState, PersonalPositionState } from "./generated";
|
|
|
3
3
|
import BN from "bn.js";
|
|
4
4
|
import { ClmmApiConfig } from "./api";
|
|
5
5
|
export interface ClmmSdkConfig {
|
|
6
|
-
/** API client config */
|
|
7
|
-
apiConfig: ClmmApiConfig;
|
|
8
6
|
/** RPC client for Solana network operations */
|
|
9
7
|
rpc: Rpc<SolanaRpcApiMainnet | SolanaRpcApiDevnet | SolanaRpcApiTestnet>;
|
|
8
|
+
/** API client config */
|
|
9
|
+
apiConfig?: ClmmApiConfig;
|
|
10
10
|
/** Optional program address override */
|
|
11
11
|
programAddress?: Address;
|
|
12
12
|
/** Default commitment level for transactions */
|
|
13
13
|
commitment?: "processed" | "confirmed" | "finalized";
|
|
14
14
|
}
|
|
15
|
-
export interface ClmmConfig {
|
|
16
|
-
id: string;
|
|
17
|
-
index: number;
|
|
18
|
-
protocolFeeRate: number;
|
|
19
|
-
tradeFeeRate: number;
|
|
20
|
-
tickSpacing: number;
|
|
21
|
-
fundFeeRate: number;
|
|
22
|
-
description: string;
|
|
23
|
-
defaultRange: number;
|
|
24
|
-
defaultRangePoint: number[];
|
|
25
|
-
}
|
|
26
15
|
/**
|
|
27
16
|
* Return type for make instructions following Raydium's pattern
|
|
28
17
|
*/
|
|
@@ -52,6 +41,21 @@ export interface PoolInfo extends PoolState {
|
|
|
52
41
|
/** Current APY for liquidity providers */
|
|
53
42
|
apy?: number;
|
|
54
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Position Data API response
|
|
46
|
+
*/
|
|
47
|
+
export type PoolApiData = {
|
|
48
|
+
tokenVault1: string;
|
|
49
|
+
tokenVault0: string;
|
|
50
|
+
ammConfig: string;
|
|
51
|
+
sqrtPriceX64: string;
|
|
52
|
+
tickSpacing: number;
|
|
53
|
+
tokenMint0: string;
|
|
54
|
+
tokenMint1: string;
|
|
55
|
+
owner: string;
|
|
56
|
+
tick: number;
|
|
57
|
+
address: string;
|
|
58
|
+
};
|
|
55
59
|
export interface TokenInfo {
|
|
56
60
|
/** Token mint address */
|
|
57
61
|
mint: Address;
|
|
@@ -64,15 +68,15 @@ export interface TokenInfo {
|
|
|
64
68
|
/** Logo URI */
|
|
65
69
|
logoUri?: string;
|
|
66
70
|
}
|
|
67
|
-
export interface
|
|
68
|
-
id: Address;
|
|
69
|
-
index: number;
|
|
70
|
-
protocolFeeRate: number;
|
|
71
|
+
export interface ClmmConfig {
|
|
71
72
|
tradeFeeRate: number;
|
|
72
|
-
|
|
73
|
+
index: number;
|
|
73
74
|
fundFeeRate: number;
|
|
75
|
+
tickSpacing: number;
|
|
74
76
|
fundOwner: string;
|
|
75
|
-
|
|
77
|
+
owner: string;
|
|
78
|
+
address: string;
|
|
79
|
+
protocolFeeRate: number;
|
|
76
80
|
}
|
|
77
81
|
export interface PositionInfo extends PersonalPositionState {
|
|
78
82
|
/** Token mint addresses from pool */
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,GAAG,EACH,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,WAAW,aAAa;IAC5B
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,GAAG,EACH,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,GAAG,EAAE,GAAG,CAAC,mBAAmB,GAAG,kBAAkB,GAAG,mBAAmB,CAAC,CAAC;IACzE,wBAAwB;IACxB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wCAAwC;IACxC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gDAA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B;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,mBAAmB;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB;IACjB,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,oBAAoB;IACpB,OAAO,EAAE;QAAE,MAAM,EAAE,EAAE,CAAC;QAAC,MAAM,EAAE,EAAE,CAAA;KAAE,CAAC;IACpC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from "./math";
|
|
|
6
6
|
export * from "./pda";
|
|
7
7
|
export * from "./tick";
|
|
8
8
|
export * from "./pool";
|
|
9
|
-
import { SignatureBytes, type Address } from "@solana/kit";
|
|
9
|
+
import { Rpc, SignatureBytes, SolanaRpcApiDevnet, SolanaRpcApiMainnet, SolanaRpcApiTestnet, type Address } from "@solana/kit";
|
|
10
10
|
/**
|
|
11
11
|
* Validate that an address is not empty
|
|
12
12
|
* @param address - Address to validate
|
|
@@ -76,4 +76,8 @@ export declare function getFakeSigner(address: Address): {
|
|
|
76
76
|
signatures: import("@solana/kit").SignaturesMap;
|
|
77
77
|
}>[], _config: import("@solana/kit").BaseTransactionSignerConfig | undefined) => Promise<SignatureBytes[]>;
|
|
78
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* A very brutal way to differentate between mainnet and devnet RPC
|
|
81
|
+
*/
|
|
82
|
+
export declare function getApisFromEndpoint(rpc: Rpc<SolanaRpcApiMainnet | SolanaRpcApiDevnet | SolanaRpcApiTestnet>): string;
|
|
79
83
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAIvB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAIvB,OAAO,EAGL,GAAG,EACH,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAEnB,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAIrB;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE,MAAkB,GACvB,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAiB,GAAG,IAAI,CAO5E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAU,GACpB,MAAM,CAmBR;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,SAAS,GAAE,MAAW,GACrB,OAAO,CAGT;AAED;;;;;;GAMG;AACH,wBAAsB,KAAK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