@stabbleorg/mclmm-sdk 0.1.0 → 0.1.2-beta.1
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 +124 -157
- package/lib/index.mjs +127 -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,
|
|
@@ -8701,12 +8641,37 @@ var PositionManager = class {
|
|
|
8701
8641
|
);
|
|
8702
8642
|
const amount0Max = base === "MintA" ? baseAmount : otherAmountMax;
|
|
8703
8643
|
const amount1Max = base === "MintA" ? otherAmountMax : baseAmount;
|
|
8704
|
-
|
|
8644
|
+
console.log({
|
|
8645
|
+
payer: ownerInfo.wallet,
|
|
8646
|
+
positionNftOwner: ownerInfo.wallet.address,
|
|
8647
|
+
positionNftMint: nftMintAccount,
|
|
8648
|
+
positionNftAccount: positionNftAccountPda,
|
|
8649
|
+
poolState: poolAccount.address,
|
|
8650
|
+
protocolPosition: protocolPositionPda,
|
|
8651
|
+
tokenAccount0: ownerInfo.tokenAccountA,
|
|
8652
|
+
tokenAccount1: ownerInfo.tokenAccountB,
|
|
8653
|
+
tokenVault0: poolAccount.data.tokenVault0,
|
|
8654
|
+
tokenVault1: poolAccount.data.tokenVault1,
|
|
8655
|
+
vault0Mint: poolAccount.data.tokenMint0,
|
|
8656
|
+
vault1Mint: poolAccount.data.tokenMint1,
|
|
8657
|
+
tickLowerIndex: tickLower,
|
|
8658
|
+
tickUpperIndex: tickUpper,
|
|
8659
|
+
tickArrayLowerStartIndex,
|
|
8660
|
+
tickArrayUpperStartIndex,
|
|
8661
|
+
tickArrayLower,
|
|
8662
|
+
tickArrayUpper,
|
|
8663
|
+
liquidity: BigInt(0),
|
|
8664
|
+
amount0Max,
|
|
8665
|
+
amount1Max,
|
|
8666
|
+
withMetadata,
|
|
8667
|
+
baseFlag: base === "MintA" ? true : false
|
|
8668
|
+
// true = MintA is base, false = MintB is base
|
|
8669
|
+
});
|
|
8670
|
+
const instruction = await getOpenPositionWithToken22NftInstructionAsync({
|
|
8705
8671
|
payer: ownerInfo.wallet,
|
|
8706
8672
|
positionNftOwner: ownerInfo.wallet.address,
|
|
8707
8673
|
positionNftMint: nftMintAccount,
|
|
8708
8674
|
positionNftAccount: positionNftAccountPda,
|
|
8709
|
-
metadataAccount: metadataPda,
|
|
8710
8675
|
poolState: poolAccount.address,
|
|
8711
8676
|
protocolPosition: protocolPositionPda,
|
|
8712
8677
|
tokenAccount0: ownerInfo.tokenAccountA,
|
|
@@ -9082,17 +9047,83 @@ var PositionManager = class {
|
|
|
9082
9047
|
}
|
|
9083
9048
|
};
|
|
9084
9049
|
|
|
9085
|
-
// src/api/
|
|
9050
|
+
// src/api/config.ts
|
|
9086
9051
|
var import_axios = __toESM(require("axios"));
|
|
9087
|
-
var
|
|
9052
|
+
var ClmmConfigApi = class {
|
|
9088
9053
|
constructor(config) {
|
|
9089
9054
|
this.config = config;
|
|
9090
9055
|
this.client = import_axios.default.create({
|
|
9091
9056
|
baseURL: this.config.baseUrl,
|
|
9092
9057
|
timeout: this.config.timeout ?? 1e4,
|
|
9093
9058
|
headers: {
|
|
9094
|
-
"Content-Type": "application/json"
|
|
9095
|
-
|
|
9059
|
+
"Content-Type": "application/json"
|
|
9060
|
+
}
|
|
9061
|
+
});
|
|
9062
|
+
}
|
|
9063
|
+
client;
|
|
9064
|
+
/**
|
|
9065
|
+
* Fetch all configs
|
|
9066
|
+
* @returns CLMM config information or null if not found
|
|
9067
|
+
*/
|
|
9068
|
+
async getClmmConfigs() {
|
|
9069
|
+
try {
|
|
9070
|
+
const response = await this.client.get("/clmm-configs");
|
|
9071
|
+
return response.data;
|
|
9072
|
+
} catch (error) {
|
|
9073
|
+
if (this.isNotFoundError(error)) return null;
|
|
9074
|
+
throw this.handleApiError(error);
|
|
9075
|
+
}
|
|
9076
|
+
}
|
|
9077
|
+
/**
|
|
9078
|
+
* Handle API errors and convert to Error
|
|
9079
|
+
* @param error - Error from axios
|
|
9080
|
+
* @returns Error with appropriate message
|
|
9081
|
+
*/
|
|
9082
|
+
handleApiError(error) {
|
|
9083
|
+
if (import_axios.default.isAxiosError(error)) {
|
|
9084
|
+
const axiosError = error;
|
|
9085
|
+
if (axiosError.code === "ECONNABORTED") {
|
|
9086
|
+
return new Error("API request timeout");
|
|
9087
|
+
}
|
|
9088
|
+
if (axiosError.response) {
|
|
9089
|
+
const status = axiosError.response.status;
|
|
9090
|
+
const message = axiosError.response.data?.message || axiosError.message;
|
|
9091
|
+
if (status === 404) {
|
|
9092
|
+
return new Error(`CLMM config not found: ${message}`);
|
|
9093
|
+
}
|
|
9094
|
+
if (status >= 500) {
|
|
9095
|
+
return new Error(`API server error: ${message}`);
|
|
9096
|
+
}
|
|
9097
|
+
return new Error(`API request failed: ${message}`);
|
|
9098
|
+
}
|
|
9099
|
+
if (axiosError.request) {
|
|
9100
|
+
return new Error("No response from API server");
|
|
9101
|
+
}
|
|
9102
|
+
}
|
|
9103
|
+
return new Error(
|
|
9104
|
+
`Unknown API error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
9105
|
+
);
|
|
9106
|
+
}
|
|
9107
|
+
/**
|
|
9108
|
+
* Check if error is a 404 Not Found
|
|
9109
|
+
* @param error - Error to check
|
|
9110
|
+
* @returns True if 404 error
|
|
9111
|
+
*/
|
|
9112
|
+
isNotFoundError(error) {
|
|
9113
|
+
return import_axios.default.isAxiosError(error) && error.response?.status === 404;
|
|
9114
|
+
}
|
|
9115
|
+
};
|
|
9116
|
+
|
|
9117
|
+
// src/api/pools.ts
|
|
9118
|
+
var import_axios2 = __toESM(require("axios"));
|
|
9119
|
+
var PoolsApi = class {
|
|
9120
|
+
constructor(config) {
|
|
9121
|
+
this.config = config;
|
|
9122
|
+
this.client = import_axios2.default.create({
|
|
9123
|
+
baseURL: this.config.baseUrl,
|
|
9124
|
+
timeout: this.config.timeout ?? 1e4,
|
|
9125
|
+
headers: {
|
|
9126
|
+
"Content-Type": "application/json"
|
|
9096
9127
|
}
|
|
9097
9128
|
});
|
|
9098
9129
|
}
|
|
@@ -9107,7 +9138,7 @@ var PoolsApi = class {
|
|
|
9107
9138
|
const response = await this.client.get(
|
|
9108
9139
|
`/pools/${poolAddress}`
|
|
9109
9140
|
);
|
|
9110
|
-
return
|
|
9141
|
+
return response.data.pool;
|
|
9111
9142
|
} catch (error) {
|
|
9112
9143
|
if (this.isNotFoundError(error)) return null;
|
|
9113
9144
|
throw this.handleApiError(error);
|
|
@@ -9120,7 +9151,7 @@ var PoolsApi = class {
|
|
|
9120
9151
|
async getAllPools() {
|
|
9121
9152
|
try {
|
|
9122
9153
|
const response = await this.client.get("/pools");
|
|
9123
|
-
return response.data
|
|
9154
|
+
return response.data;
|
|
9124
9155
|
} catch (error) {
|
|
9125
9156
|
throw this.handleApiError(error);
|
|
9126
9157
|
}
|
|
@@ -9139,81 +9170,19 @@ var PoolsApi = class {
|
|
|
9139
9170
|
tokenB
|
|
9140
9171
|
}
|
|
9141
9172
|
});
|
|
9142
|
-
return response.data
|
|
9173
|
+
return response.data;
|
|
9143
9174
|
} catch (error) {
|
|
9144
9175
|
if (this.isNotFoundError(error)) return [];
|
|
9145
9176
|
throw this.handleApiError(error);
|
|
9146
9177
|
}
|
|
9147
9178
|
}
|
|
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
9179
|
/**
|
|
9211
9180
|
* Handle API errors and convert to Error
|
|
9212
9181
|
* @param error - Error from axios
|
|
9213
9182
|
* @returns Error with appropriate message
|
|
9214
9183
|
*/
|
|
9215
9184
|
handleApiError(error) {
|
|
9216
|
-
if (
|
|
9185
|
+
if (import_axios2.default.isAxiosError(error)) {
|
|
9217
9186
|
const axiosError = error;
|
|
9218
9187
|
if (axiosError.code === "ECONNABORTED") {
|
|
9219
9188
|
return new Error("API request timeout");
|
|
@@ -9243,7 +9212,7 @@ var PoolsApi = class {
|
|
|
9243
9212
|
* @returns True if 404 error
|
|
9244
9213
|
*/
|
|
9245
9214
|
isNotFoundError(error) {
|
|
9246
|
-
return
|
|
9215
|
+
return import_axios2.default.isAxiosError(error) && error.response?.status === 404;
|
|
9247
9216
|
}
|
|
9248
9217
|
};
|
|
9249
9218
|
|
|
@@ -9252,8 +9221,10 @@ var ClmmApi = class {
|
|
|
9252
9221
|
constructor(config) {
|
|
9253
9222
|
this.config = config;
|
|
9254
9223
|
this.pools = new PoolsApi(this.config);
|
|
9224
|
+
this.clmmConfig = new ClmmConfigApi(this.config);
|
|
9255
9225
|
}
|
|
9256
9226
|
pools;
|
|
9227
|
+
clmmConfig;
|
|
9257
9228
|
};
|
|
9258
9229
|
|
|
9259
9230
|
// src/client.ts
|
|
@@ -9275,7 +9246,9 @@ var ClmmSdk = class _ClmmSdk {
|
|
|
9275
9246
|
constructor(config) {
|
|
9276
9247
|
this.config = config;
|
|
9277
9248
|
this.clmm = new Clmm(config);
|
|
9278
|
-
|
|
9249
|
+
const baseUrl = getApisFromEndpoint(config.rpc);
|
|
9250
|
+
const apiConfig = config.apiConfig ? config.apiConfig : { baseUrl };
|
|
9251
|
+
this.api = new ClmmApi(apiConfig);
|
|
9279
9252
|
this.pools = new PoolManager(config);
|
|
9280
9253
|
this.positions = new PositionManager(config);
|
|
9281
9254
|
}
|
|
@@ -9317,20 +9290,16 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9317
9290
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9318
9291
|
0 && (module.exports = {
|
|
9319
9292
|
AMM_V3_PROGRAM_ADDRESS,
|
|
9293
|
+
API_ENDPONTS,
|
|
9320
9294
|
BIT_PRECISION,
|
|
9321
9295
|
Clmm,
|
|
9322
9296
|
ClmmSdk,
|
|
9323
|
-
DEFAULT_COMPUTE_UNITS,
|
|
9324
9297
|
DEFAULT_CONFIG,
|
|
9325
9298
|
DEFAULT_DEADLINE_SECONDS,
|
|
9326
9299
|
DEFAULT_SDK_CONFIG,
|
|
9327
9300
|
DEFAULT_SLIPPAGE_TOLERANCE,
|
|
9328
|
-
DISCRIMINATORS,
|
|
9329
|
-
ERROR_MESSAGES,
|
|
9330
|
-
FEE_PRECISION,
|
|
9331
9301
|
FEE_RATE_DENOMINATOR,
|
|
9332
9302
|
FEE_TIERS,
|
|
9333
|
-
LIQUIDITY_PRECISION,
|
|
9334
9303
|
LOG_B_2_X32,
|
|
9335
9304
|
LOG_B_P_ERR_MARGIN_LOWER_X64,
|
|
9336
9305
|
LOG_B_P_ERR_MARGIN_UPPER_X64,
|
|
@@ -9348,8 +9317,6 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9348
9317
|
NEGATIVE_ONE,
|
|
9349
9318
|
ONE,
|
|
9350
9319
|
PDA_SEEDS,
|
|
9351
|
-
PRICE_PRECISION,
|
|
9352
|
-
PRIORITY_FEE_MICRO_LAMPORTS,
|
|
9353
9320
|
PdaUtils,
|
|
9354
9321
|
PoolManager,
|
|
9355
9322
|
PoolUtils,
|
|
@@ -9367,7 +9334,6 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9367
9334
|
TickMath,
|
|
9368
9335
|
TickUtils,
|
|
9369
9336
|
U64Resolution,
|
|
9370
|
-
WELL_KNOWN_TOKENS,
|
|
9371
9337
|
ZERO,
|
|
9372
9338
|
addresstoBytes,
|
|
9373
9339
|
approximatelyEqual,
|
|
@@ -9383,6 +9349,7 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9383
9349
|
formatAmount,
|
|
9384
9350
|
generated,
|
|
9385
9351
|
getAmmV3ErrorMessage,
|
|
9352
|
+
getApisFromEndpoint,
|
|
9386
9353
|
getClosePositionInstruction,
|
|
9387
9354
|
getCreateAmmConfigInstruction,
|
|
9388
9355
|
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,
|
|
@@ -9336,12 +9279,37 @@ var PositionManager = class {
|
|
|
9336
9279
|
);
|
|
9337
9280
|
const amount0Max = base === "MintA" ? baseAmount : otherAmountMax;
|
|
9338
9281
|
const amount1Max = base === "MintA" ? otherAmountMax : baseAmount;
|
|
9339
|
-
|
|
9282
|
+
console.log({
|
|
9283
|
+
payer: ownerInfo.wallet,
|
|
9284
|
+
positionNftOwner: ownerInfo.wallet.address,
|
|
9285
|
+
positionNftMint: nftMintAccount,
|
|
9286
|
+
positionNftAccount: positionNftAccountPda,
|
|
9287
|
+
poolState: poolAccount.address,
|
|
9288
|
+
protocolPosition: protocolPositionPda,
|
|
9289
|
+
tokenAccount0: ownerInfo.tokenAccountA,
|
|
9290
|
+
tokenAccount1: ownerInfo.tokenAccountB,
|
|
9291
|
+
tokenVault0: poolAccount.data.tokenVault0,
|
|
9292
|
+
tokenVault1: poolAccount.data.tokenVault1,
|
|
9293
|
+
vault0Mint: poolAccount.data.tokenMint0,
|
|
9294
|
+
vault1Mint: poolAccount.data.tokenMint1,
|
|
9295
|
+
tickLowerIndex: tickLower,
|
|
9296
|
+
tickUpperIndex: tickUpper,
|
|
9297
|
+
tickArrayLowerStartIndex,
|
|
9298
|
+
tickArrayUpperStartIndex,
|
|
9299
|
+
tickArrayLower,
|
|
9300
|
+
tickArrayUpper,
|
|
9301
|
+
liquidity: BigInt(0),
|
|
9302
|
+
amount0Max,
|
|
9303
|
+
amount1Max,
|
|
9304
|
+
withMetadata,
|
|
9305
|
+
baseFlag: base === "MintA" ? true : false
|
|
9306
|
+
// true = MintA is base, false = MintB is base
|
|
9307
|
+
});
|
|
9308
|
+
const instruction = await getOpenPositionWithToken22NftInstructionAsync({
|
|
9340
9309
|
payer: ownerInfo.wallet,
|
|
9341
9310
|
positionNftOwner: ownerInfo.wallet.address,
|
|
9342
9311
|
positionNftMint: nftMintAccount,
|
|
9343
9312
|
positionNftAccount: positionNftAccountPda,
|
|
9344
|
-
metadataAccount: metadataPda,
|
|
9345
9313
|
poolState: poolAccount.address,
|
|
9346
9314
|
protocolPosition: protocolPositionPda,
|
|
9347
9315
|
tokenAccount0: ownerInfo.tokenAccountA,
|
|
@@ -9717,17 +9685,83 @@ var PositionManager = class {
|
|
|
9717
9685
|
}
|
|
9718
9686
|
};
|
|
9719
9687
|
|
|
9720
|
-
// src/api/
|
|
9688
|
+
// src/api/config.ts
|
|
9721
9689
|
import axios from "axios";
|
|
9722
|
-
var
|
|
9690
|
+
var ClmmConfigApi = class {
|
|
9723
9691
|
constructor(config) {
|
|
9724
9692
|
this.config = config;
|
|
9725
9693
|
this.client = axios.create({
|
|
9726
9694
|
baseURL: this.config.baseUrl,
|
|
9727
9695
|
timeout: this.config.timeout ?? 1e4,
|
|
9728
9696
|
headers: {
|
|
9729
|
-
"Content-Type": "application/json"
|
|
9730
|
-
|
|
9697
|
+
"Content-Type": "application/json"
|
|
9698
|
+
}
|
|
9699
|
+
});
|
|
9700
|
+
}
|
|
9701
|
+
client;
|
|
9702
|
+
/**
|
|
9703
|
+
* Fetch all configs
|
|
9704
|
+
* @returns CLMM config information or null if not found
|
|
9705
|
+
*/
|
|
9706
|
+
async getClmmConfigs() {
|
|
9707
|
+
try {
|
|
9708
|
+
const response = await this.client.get("/clmm-configs");
|
|
9709
|
+
return response.data;
|
|
9710
|
+
} catch (error) {
|
|
9711
|
+
if (this.isNotFoundError(error)) return null;
|
|
9712
|
+
throw this.handleApiError(error);
|
|
9713
|
+
}
|
|
9714
|
+
}
|
|
9715
|
+
/**
|
|
9716
|
+
* Handle API errors and convert to Error
|
|
9717
|
+
* @param error - Error from axios
|
|
9718
|
+
* @returns Error with appropriate message
|
|
9719
|
+
*/
|
|
9720
|
+
handleApiError(error) {
|
|
9721
|
+
if (axios.isAxiosError(error)) {
|
|
9722
|
+
const axiosError = error;
|
|
9723
|
+
if (axiosError.code === "ECONNABORTED") {
|
|
9724
|
+
return new Error("API request timeout");
|
|
9725
|
+
}
|
|
9726
|
+
if (axiosError.response) {
|
|
9727
|
+
const status = axiosError.response.status;
|
|
9728
|
+
const message = axiosError.response.data?.message || axiosError.message;
|
|
9729
|
+
if (status === 404) {
|
|
9730
|
+
return new Error(`CLMM config not found: ${message}`);
|
|
9731
|
+
}
|
|
9732
|
+
if (status >= 500) {
|
|
9733
|
+
return new Error(`API server error: ${message}`);
|
|
9734
|
+
}
|
|
9735
|
+
return new Error(`API request failed: ${message}`);
|
|
9736
|
+
}
|
|
9737
|
+
if (axiosError.request) {
|
|
9738
|
+
return new Error("No response from API server");
|
|
9739
|
+
}
|
|
9740
|
+
}
|
|
9741
|
+
return new Error(
|
|
9742
|
+
`Unknown API error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
9743
|
+
);
|
|
9744
|
+
}
|
|
9745
|
+
/**
|
|
9746
|
+
* Check if error is a 404 Not Found
|
|
9747
|
+
* @param error - Error to check
|
|
9748
|
+
* @returns True if 404 error
|
|
9749
|
+
*/
|
|
9750
|
+
isNotFoundError(error) {
|
|
9751
|
+
return axios.isAxiosError(error) && error.response?.status === 404;
|
|
9752
|
+
}
|
|
9753
|
+
};
|
|
9754
|
+
|
|
9755
|
+
// src/api/pools.ts
|
|
9756
|
+
import axios2 from "axios";
|
|
9757
|
+
var PoolsApi = class {
|
|
9758
|
+
constructor(config) {
|
|
9759
|
+
this.config = config;
|
|
9760
|
+
this.client = axios2.create({
|
|
9761
|
+
baseURL: this.config.baseUrl,
|
|
9762
|
+
timeout: this.config.timeout ?? 1e4,
|
|
9763
|
+
headers: {
|
|
9764
|
+
"Content-Type": "application/json"
|
|
9731
9765
|
}
|
|
9732
9766
|
});
|
|
9733
9767
|
}
|
|
@@ -9742,7 +9776,7 @@ var PoolsApi = class {
|
|
|
9742
9776
|
const response = await this.client.get(
|
|
9743
9777
|
`/pools/${poolAddress}`
|
|
9744
9778
|
);
|
|
9745
|
-
return
|
|
9779
|
+
return response.data.pool;
|
|
9746
9780
|
} catch (error) {
|
|
9747
9781
|
if (this.isNotFoundError(error)) return null;
|
|
9748
9782
|
throw this.handleApiError(error);
|
|
@@ -9755,7 +9789,7 @@ var PoolsApi = class {
|
|
|
9755
9789
|
async getAllPools() {
|
|
9756
9790
|
try {
|
|
9757
9791
|
const response = await this.client.get("/pools");
|
|
9758
|
-
return response.data
|
|
9792
|
+
return response.data;
|
|
9759
9793
|
} catch (error) {
|
|
9760
9794
|
throw this.handleApiError(error);
|
|
9761
9795
|
}
|
|
@@ -9774,81 +9808,19 @@ var PoolsApi = class {
|
|
|
9774
9808
|
tokenB
|
|
9775
9809
|
}
|
|
9776
9810
|
});
|
|
9777
|
-
return response.data
|
|
9811
|
+
return response.data;
|
|
9778
9812
|
} catch (error) {
|
|
9779
9813
|
if (this.isNotFoundError(error)) return [];
|
|
9780
9814
|
throw this.handleApiError(error);
|
|
9781
9815
|
}
|
|
9782
9816
|
}
|
|
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
9817
|
/**
|
|
9846
9818
|
* Handle API errors and convert to Error
|
|
9847
9819
|
* @param error - Error from axios
|
|
9848
9820
|
* @returns Error with appropriate message
|
|
9849
9821
|
*/
|
|
9850
9822
|
handleApiError(error) {
|
|
9851
|
-
if (
|
|
9823
|
+
if (axios2.isAxiosError(error)) {
|
|
9852
9824
|
const axiosError = error;
|
|
9853
9825
|
if (axiosError.code === "ECONNABORTED") {
|
|
9854
9826
|
return new Error("API request timeout");
|
|
@@ -9878,7 +9850,7 @@ var PoolsApi = class {
|
|
|
9878
9850
|
* @returns True if 404 error
|
|
9879
9851
|
*/
|
|
9880
9852
|
isNotFoundError(error) {
|
|
9881
|
-
return
|
|
9853
|
+
return axios2.isAxiosError(error) && error.response?.status === 404;
|
|
9882
9854
|
}
|
|
9883
9855
|
};
|
|
9884
9856
|
|
|
@@ -9887,8 +9859,10 @@ var ClmmApi = class {
|
|
|
9887
9859
|
constructor(config) {
|
|
9888
9860
|
this.config = config;
|
|
9889
9861
|
this.pools = new PoolsApi(this.config);
|
|
9862
|
+
this.clmmConfig = new ClmmConfigApi(this.config);
|
|
9890
9863
|
}
|
|
9891
9864
|
pools;
|
|
9865
|
+
clmmConfig;
|
|
9892
9866
|
};
|
|
9893
9867
|
|
|
9894
9868
|
// src/client.ts
|
|
@@ -9910,7 +9884,9 @@ var ClmmSdk = class _ClmmSdk {
|
|
|
9910
9884
|
constructor(config) {
|
|
9911
9885
|
this.config = config;
|
|
9912
9886
|
this.clmm = new Clmm(config);
|
|
9913
|
-
|
|
9887
|
+
const baseUrl = getApisFromEndpoint(config.rpc);
|
|
9888
|
+
const apiConfig = config.apiConfig ? config.apiConfig : { baseUrl };
|
|
9889
|
+
this.api = new ClmmApi(apiConfig);
|
|
9914
9890
|
this.pools = new PoolManager(config);
|
|
9915
9891
|
this.positions = new PositionManager(config);
|
|
9916
9892
|
}
|
|
@@ -9951,20 +9927,16 @@ var DEFAULT_SDK_CONFIG = {
|
|
|
9951
9927
|
};
|
|
9952
9928
|
export {
|
|
9953
9929
|
AMM_V3_PROGRAM_ADDRESS,
|
|
9930
|
+
API_ENDPONTS,
|
|
9954
9931
|
BIT_PRECISION,
|
|
9955
9932
|
Clmm,
|
|
9956
9933
|
ClmmSdk,
|
|
9957
|
-
DEFAULT_COMPUTE_UNITS,
|
|
9958
9934
|
DEFAULT_CONFIG,
|
|
9959
9935
|
DEFAULT_DEADLINE_SECONDS,
|
|
9960
9936
|
DEFAULT_SDK_CONFIG,
|
|
9961
9937
|
DEFAULT_SLIPPAGE_TOLERANCE,
|
|
9962
|
-
DISCRIMINATORS,
|
|
9963
|
-
ERROR_MESSAGES,
|
|
9964
|
-
FEE_PRECISION,
|
|
9965
9938
|
FEE_RATE_DENOMINATOR,
|
|
9966
9939
|
FEE_TIERS,
|
|
9967
|
-
LIQUIDITY_PRECISION,
|
|
9968
9940
|
LOG_B_2_X32,
|
|
9969
9941
|
LOG_B_P_ERR_MARGIN_LOWER_X64,
|
|
9970
9942
|
LOG_B_P_ERR_MARGIN_UPPER_X64,
|
|
@@ -9982,8 +9954,6 @@ export {
|
|
|
9982
9954
|
NEGATIVE_ONE,
|
|
9983
9955
|
ONE,
|
|
9984
9956
|
PDA_SEEDS,
|
|
9985
|
-
PRICE_PRECISION,
|
|
9986
|
-
PRIORITY_FEE_MICRO_LAMPORTS,
|
|
9987
9957
|
PdaUtils,
|
|
9988
9958
|
PoolManager,
|
|
9989
9959
|
PoolUtils,
|
|
@@ -10001,7 +9971,6 @@ export {
|
|
|
10001
9971
|
TickMath,
|
|
10002
9972
|
TickUtils,
|
|
10003
9973
|
U64Resolution,
|
|
10004
|
-
WELL_KNOWN_TOKENS,
|
|
10005
9974
|
ZERO,
|
|
10006
9975
|
addresstoBytes,
|
|
10007
9976
|
approximatelyEqual,
|
|
@@ -10017,6 +9986,7 @@ export {
|
|
|
10017
9986
|
formatAmount,
|
|
10018
9987
|
generated_exports as generated,
|
|
10019
9988
|
getAmmV3ErrorMessage,
|
|
9989
|
+
getApisFromEndpoint,
|
|
10020
9990
|
getClosePositionInstruction,
|
|
10021
9991
|
getCreateAmmConfigInstruction,
|
|
10022
9992
|
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","sourceRo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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,gDAAgD;IAChD,UAAU,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;CACtD;AAGD;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,EAAE;IAC3C,4BAA4B;IAC5B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,uBAAuB;IACvB,OAAO,EAAE,iBAAiB,EAAE,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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,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