100x-sdk 1.0.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/src/sdk.js ADDED
@@ -0,0 +1,206 @@
1
+ const anchor = require('@coral-xyz/anchor');
2
+ const { PublicKey } = require('@solana/web3.js');
3
+ // 统一使用 buffer 包,所有平台一致
4
+ const { Buffer } = require('buffer');
5
+
6
+ // 环境检测和条件加载
7
+ const IS_NODE = typeof process !== 'undefined' && process.versions && process.versions.node;
8
+
9
+ // 确保全局可用(兼容现有代码)
10
+ if (typeof global !== 'undefined' && !global.Buffer) {
11
+ global.Buffer = Buffer;
12
+ }
13
+
14
+ const TradingModule = require('./modules/trading');
15
+ const TokenModule = require('./modules/token');
16
+ const ParamModule = require('./modules/param');
17
+ const FastModule = require('./modules/fast');
18
+ const SimulatorModule = require('./modules/simulator');
19
+ const ChainModule = require('./modules/chain');
20
+ const ToolsModule = require('./modules/tools');
21
+ const OrderUtils = require('./utils/orderUtils');
22
+ const CurveAMM = require('./utils/curve_amm');
23
+ const idlLocalnet = require('./idl/fun100x_localnet.json');
24
+ const idlMain = require('./idl/fun100x_main.json');
25
+
26
+ function getIdlByNetwork(network) {
27
+ if (network === 'localnet') return idlLocalnet;
28
+ return idlMain;
29
+ }
30
+
31
+ /**
32
+ * 100x SDK Main Class
33
+ * Provides modular interfaces for interacting with 100x protocol
34
+ */
35
+ class Fun100xSdk {
36
+ /**
37
+ * Constructor
38
+ * @param {Connection} connection - Solana connection instance
39
+ * @param {Wallet|Keypair} wallet - Wallet instance
40
+ * @param {PublicKey|string} programId - Program ID
41
+ * @param {Object} options - Configuration options (optional)
42
+ */
43
+ constructor(connection, programId, options = {}) {
44
+ //console.log("Fun100xSdk options=",options)
45
+ // Save configuration options
46
+ this.options = options;
47
+
48
+ // Validate defaultDataSource configuration
49
+ if (options.defaultDataSource && !['fast', 'chain'].includes(options.defaultDataSource)) {
50
+ throw new Error('defaultDataSource must be "fast" or "chain"');
51
+ }
52
+
53
+ //console.log("options.defaultDataSource",options.defaultDataSource)
54
+ //this.defaultDataSource = options.defaultDataSource || 'fast';
55
+ this.defaultDataSource = options.defaultDataSource || 'chain';
56
+
57
+ console.log('Data source method:', this.defaultDataSource);
58
+
59
+ // Basic configuration
60
+ this.connection = connection;
61
+ //this.wallet = wallet instanceof anchor.Wallet ? wallet : new anchor.Wallet(wallet);
62
+ this.programId = typeof programId === 'string' ? new PublicKey(programId) : programId;
63
+ this.idl = getIdlByNetwork(options.network);
64
+
65
+ // Initialize account configuration with options
66
+ this.feeRecipient = this._parsePublicKey(this.options.feeRecipient);
67
+ this.baseFeeRecipient = this._parsePublicKey(this.options.baseFeeRecipient);
68
+ this.paramsAccount = this._parsePublicKey(this.options.paramsAccount);
69
+ this.fastApiUrl = this.options.fastApiUrl;
70
+
71
+ // Maximum number of orders that can be processed at once in the contract
72
+ this.MAX_ORDERS_COUNT = 50
73
+ // Maximum number of orders to fetch during queries
74
+ this.FIND_MAX_ORDERS_COUNT = 1000
75
+
76
+ // 在流动性不足时, 建议实际使用流动性的比例, 分每 (1000=100%)
77
+ this.SUGGEST_LIQ_RATIO = 975; // 97.5% (1000=100%)
78
+
79
+ // Initialize Anchor program
80
+ this.program = this._initProgram(this.options);
81
+
82
+ // Initialize functional modules
83
+ this.trading = new TradingModule(this);
84
+ this.token = new TokenModule(this);
85
+ this.param = new ParamModule(this);
86
+ this.fast = new FastModule(this);
87
+ this.simulator = new SimulatorModule(this);
88
+ this.chain = new ChainModule(this);
89
+ this.tools = new ToolsModule(this);
90
+
91
+ // Initialize curve AMM utility
92
+ this.curve = CurveAMM;
93
+
94
+ /**
95
+ * 统一数据接口 - 根据 defaultDataSource 配置自动路由到 fast 或 chain 模块
96
+ * Unified data interface - automatically routes to fast or chain module based on defaultDataSource config
97
+ *
98
+ * @example
99
+ * // 使用默认数据源获取订单
100
+ * const ordersData = await sdk.data.orders(mint, { type: 'down_orders' });
101
+ *
102
+ * // 临时指定数据源
103
+ * const ordersData = await sdk.data.orders(mint, {
104
+ * type: 'down_orders',
105
+ * dataSource: 'chain' // 临时使用链上数据源
106
+ * });
107
+ *
108
+ * // 获取用户订单
109
+ * const userOrders = await sdk.data.user_orders(user, mint, {
110
+ * page: 1,
111
+ * limit: 200,
112
+ * order_by: 'start_time_desc'
113
+ * });
114
+ */
115
+ this.data = {
116
+ /**
117
+ * 获取代币订单数据
118
+ * @param {string} mint - 代币地址
119
+ * @param {Object} options - 查询参数,支持 dataSource 字段临时指定数据源
120
+ * @returns {Promise<Object>} 订单数据
121
+ */
122
+ orders: (mint, options = {}) => this._getDataWithSource('orders', [mint, options]),
123
+
124
+ /**
125
+ * 获取代币价格数据
126
+ * @param {string} mint - 代币地址
127
+ * @param {Object} options - 查询参数,支持 dataSource 字段临时指定数据源
128
+ * @returns {Promise<string>} 价格字符串
129
+ */
130
+ price: (mint, options = {}) => this._getDataWithSource('price', [mint, options]),
131
+
132
+ /**
133
+ * 获取用户订单数据
134
+ * @param {string} user - 用户地址
135
+ * @param {string} mint - 代币地址
136
+ * @param {Object} options - 查询参数,支持 dataSource 字段临时指定数据源
137
+ * @returns {Promise<Object>} 用户订单数据
138
+ */
139
+ user_orders: (user, mint, options = {}) => this._getDataWithSource('user_orders', [user, mint, options])
140
+ };
141
+ }
142
+
143
+ /**
144
+ * Parse PublicKey
145
+ * @private
146
+ * @param {PublicKey|string|null} key - Key to parse
147
+ * @returns {PublicKey|null}
148
+ */
149
+ _parsePublicKey(key) {
150
+ if (!key) return null;
151
+ return typeof key === 'string' ? new PublicKey(key) : key;
152
+ }
153
+
154
+ /**
155
+ * Initialize Anchor program instance
156
+ * @private
157
+ */
158
+ _initProgram(options = {}) {
159
+ const provider = new anchor.AnchorProvider(
160
+ this.connection,
161
+ {
162
+ commitment: options.commitment,
163
+ preflightCommitment: options.preflightCommitment,
164
+ skipPreflight: options.skipPreflight || false,
165
+ maxRetries: options.maxRetries,
166
+ ...options
167
+ }
168
+ );
169
+
170
+ anchor.setProvider(provider);
171
+
172
+ return new anchor.Program(this.idl, this.programId);
173
+ }
174
+
175
+ // ========== Unified Data Interface Routing Method ==========
176
+
177
+ /**
178
+ * Route data requests based on configuration
179
+ *
180
+ * @private
181
+ * @param {string} method - Method name
182
+ * @param {Array} args - Arguments array
183
+ * @returns {Promise} Returns result from corresponding module method
184
+ */
185
+ _getDataWithSource(method, args) {
186
+ // Extract dataSource configuration from last parameter
187
+ const lastArg = args[args.length - 1] || {};
188
+ const dataSource = lastArg.dataSource || this.defaultDataSource;
189
+
190
+ // Route to corresponding module based on data source
191
+ const module = dataSource === 'chain' ? this.chain : this.fast;
192
+
193
+ if (!module[method]) {
194
+ throw new Error(`Method ${method} does not exist in ${dataSource} module`);
195
+ }
196
+
197
+ return module[method](...args);
198
+ }
199
+
200
+ }
201
+
202
+ // 将工具类作为静态属性添加到 Fun100xSdk 类
203
+ Fun100xSdk.CurveAMM = CurveAMM;
204
+ Fun100xSdk.OrderUtils = OrderUtils;
205
+
206
+ module.exports = Fun100xSdk;
@@ -0,0 +1,386 @@
1
+ import { Connection, PublicKey, Transaction, Keypair } from '@solana/web3.js';
2
+ import { BN, Wallet, Program } from '@coral-xyz/anchor';
3
+
4
+ // ========================= 基础类型定义 =========================
5
+
6
+ export type DataSourceType = 'fast' | 'chain';
7
+
8
+ export type NetworkType = 'mainnet' | 'localnet';
9
+
10
+ export interface NetworkConfig {
11
+ name: string;
12
+ network: NetworkType;
13
+ programId: string;
14
+ defaultDataSource: DataSourceType;
15
+ solanaEndpoint: string;
16
+ fastApiUrl: string;
17
+ feeRecipient: string;
18
+ baseFeeRecipient: string;
19
+ paramsAccount: string;
20
+ }
21
+
22
+ export interface Fun100xSdkOptions {
23
+ network?: NetworkType;
24
+ defaultDataSource?: DataSourceType;
25
+ solanaEndpoint?: string;
26
+ fastApiUrl?: string;
27
+ feeRecipient?: string;
28
+ baseFeeRecipient?: string;
29
+ paramsAccount?: string;
30
+ }
31
+
32
+ // ========================= 订单和交易相关类型 =========================
33
+
34
+ export interface OrderData {
35
+ order_pda: string;
36
+ user: string;
37
+ mint: string;
38
+ order_type: string;
39
+ lock_lp_sol_amount: string;
40
+ lock_lp_token_amount: string;
41
+ lock_lp_start_price: string;
42
+ lock_lp_end_price: string;
43
+ margin_sol_amount: string;
44
+ borrow_amount: string;
45
+ position_asset_amount: string;
46
+ created_at?: string;
47
+ updated_at?: string;
48
+ }
49
+
50
+ export interface LpPair {
51
+ solAmount: BN;
52
+ tokenAmount: BN;
53
+ }
54
+
55
+ export interface TransactionResult {
56
+ transaction: Transaction;
57
+ signers: Keypair[];
58
+ accounts: Record<string, PublicKey>;
59
+ orderData?: {
60
+ ordersUsed: number;
61
+ lpPairsCount: number;
62
+ lpPairs: LpPair[];
63
+ orderAccounts: (string | null)[];
64
+ [key: string]: any;
65
+ };
66
+ }
67
+
68
+ export interface OrdersResponse {
69
+ data: {
70
+ orders: OrderData[];
71
+ total?: number;
72
+ page?: number;
73
+ limit?: number;
74
+ };
75
+ }
76
+
77
+ export interface PriceResponse {
78
+ price: string;
79
+ price_u128: string;
80
+ [key: string]: any;
81
+ }
82
+
83
+ export interface MintInfo {
84
+ mint: string;
85
+ name?: string;
86
+ symbol?: string;
87
+ decimals: number;
88
+ total_supply?: string;
89
+ [key: string]: any;
90
+ }
91
+
92
+ // ========================= 交易参数类型 =========================
93
+
94
+ export interface BuyParams {
95
+ mintAccount: string | PublicKey;
96
+ buyTokenAmount: BN;
97
+ maxSolAmount: BN;
98
+ payer: PublicKey;
99
+ }
100
+
101
+ export interface SellParams {
102
+ mintAccount: string | PublicKey;
103
+ sellTokenAmount: BN;
104
+ minSolOutput: BN;
105
+ payer: PublicKey;
106
+ }
107
+
108
+ export interface LongParams {
109
+ mintAccount: string | PublicKey;
110
+ buyTokenAmount: BN;
111
+ maxSolAmount: BN;
112
+ marginSol: BN;
113
+ closePrice: BN;
114
+ prevOrder?: PublicKey | null;
115
+ nextOrder?: PublicKey | null;
116
+ payer: PublicKey;
117
+ }
118
+
119
+ export interface ShortParams {
120
+ mintAccount: string | PublicKey;
121
+ borrowSellTokenAmount: BN;
122
+ minSolOutput: BN;
123
+ marginSol: BN;
124
+ closePrice: BN;
125
+ prevOrder?: PublicKey | null;
126
+ nextOrder?: PublicKey | null;
127
+ payer: PublicKey;
128
+ }
129
+
130
+ export interface CloseLongParams {
131
+ mintAccount: string | PublicKey;
132
+ closeOrder: string | PublicKey;
133
+ sellTokenAmount: BN;
134
+ minSolOutput: BN;
135
+ payer: PublicKey;
136
+ }
137
+
138
+ export interface CloseShortParams {
139
+ mintAccount: string | PublicKey;
140
+ closeOrder: string | PublicKey;
141
+ buyTokenAmount: BN;
142
+ maxSolAmount: BN;
143
+ payer: PublicKey;
144
+ }
145
+
146
+ export interface TransactionOptions {
147
+ computeUnits?: number;
148
+ }
149
+
150
+ // ========================= 查询参数类型 =========================
151
+
152
+ export interface OrdersQueryOptions {
153
+ type?: 'up_orders' | 'down_orders';
154
+ limit?: number;
155
+ page?: number;
156
+ dataSource?: DataSourceType;
157
+ }
158
+
159
+ export interface PriceQueryOptions {
160
+ dataSource?: DataSourceType;
161
+ }
162
+
163
+ export interface UserOrdersQueryOptions {
164
+ type?: 'up_orders' | 'down_orders';
165
+ limit?: number;
166
+ page?: number;
167
+ dataSource?: DataSourceType;
168
+ }
169
+
170
+ // ========================= 模拟器相关类型 =========================
171
+
172
+ export interface SimulationResult {
173
+ liqResult: {
174
+ free_lp_sol_amount_sum: bigint;
175
+ free_lp_token_amount_sum: bigint;
176
+ lock_lp_sol_amount_sum: bigint;
177
+ lock_lp_token_amount_sum: bigint;
178
+ has_infinite_lp: boolean;
179
+ pass_order_id: number;
180
+ force_close_num: number;
181
+ ideal_lp_sol_amount: bigint;
182
+ real_lp_sol_amount: bigint;
183
+ };
184
+ completion: string;
185
+ slippage: string;
186
+ suggestedTokenAmount: string;
187
+ suggestedSolAmount: string;
188
+ }
189
+
190
+ // ========================= 工具类相关类型 =========================
191
+
192
+ export interface FindPrevNextResult {
193
+ prevOrder: OrderData | null;
194
+ nextOrder: OrderData | null;
195
+ }
196
+
197
+ export interface ValidationResult {
198
+ valid: boolean;
199
+ errors: string[];
200
+ warnings: string[];
201
+ }
202
+
203
+ // ========================= 模块接口定义 =========================
204
+
205
+ export interface TradingModule {
206
+ buy(params: BuyParams, options?: TransactionOptions): Promise<TransactionResult>;
207
+ sell(params: SellParams, options?: TransactionOptions): Promise<TransactionResult>;
208
+ long(params: LongParams, options?: TransactionOptions): Promise<TransactionResult>;
209
+ short(params: ShortParams, options?: TransactionOptions): Promise<TransactionResult>;
210
+ closeLong(params: CloseLongParams, options?: TransactionOptions): Promise<TransactionResult>;
211
+ closeShort(params: CloseShortParams, options?: TransactionOptions): Promise<TransactionResult>;
212
+ }
213
+
214
+ export interface FastModule {
215
+ mints(options?: any): Promise<any>;
216
+ mint_info(mint: string): Promise<MintInfo>;
217
+ orders(mint: string, options?: OrdersQueryOptions): Promise<OrdersResponse>;
218
+ price(mint: string, options?: PriceQueryOptions): Promise<PriceResponse>;
219
+ user_orders(user: string, mint: string, options?: UserOrdersQueryOptions): Promise<OrdersResponse>;
220
+ }
221
+
222
+ export interface ChainModule {
223
+ getCurveAccount(mint: string): Promise<any>;
224
+ orders(mint: string, options?: OrdersQueryOptions): Promise<OrdersResponse>;
225
+ price(mint: string, options?: PriceQueryOptions): Promise<PriceResponse>;
226
+ }
227
+
228
+ export interface TokenModule {
229
+ create(params: any): Promise<TransactionResult>;
230
+ }
231
+
232
+ export interface ParamModule {
233
+ createParams(params: any): Promise<TransactionResult>;
234
+ getParams(partner: string): Promise<any>;
235
+ getAdmin(): Promise<any>;
236
+ }
237
+
238
+ export interface SimulatorModule {
239
+ simulateTokenBuy(mint: string, buyTokenAmount: bigint | string | number, passOrder?: string | null): Promise<SimulationResult>;
240
+ simulateTokenSell(mint: string, sellTokenAmount: bigint | string | number, passOrder?: string | null): Promise<SimulationResult>;
241
+ simulateLongStopLoss(mint: string, buyTokenAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any): Promise<any>;
242
+ simulateSellStopLoss(mint: string, sellTokenAmount: bigint | string | number, stopLossPrice: bigint | string | number, lastPrice?: any, ordersData?: any): Promise<any>;
243
+ }
244
+
245
+ // ========================= 数据接口类型 =========================
246
+
247
+ export interface DataInterface {
248
+ orders(mint: string, options?: OrdersQueryOptions): Promise<OrdersResponse>;
249
+ price(mint: string, options?: PriceQueryOptions): Promise<PriceResponse>;
250
+ }
251
+
252
+ // ========================= 主 SDK 类型定义 =========================
253
+
254
+ export declare class Fun100xSdk {
255
+ connection: Connection;
256
+ programId: PublicKey;
257
+ program: Program;
258
+ options: Fun100xSdkOptions;
259
+ defaultDataSource: DataSourceType;
260
+ feeRecipient: PublicKey;
261
+ baseFeeRecipient: PublicKey;
262
+ paramsAccount: PublicKey;
263
+ fastApiUrl: string;
264
+
265
+ // 常量
266
+ readonly MAX_ORDERS_COUNT: number;
267
+ readonly FIND_MAX_ORDERS_COUNT: number;
268
+ readonly SUGGEST_LIQ_RATIO: number;
269
+
270
+ // 模块
271
+ trading: TradingModule;
272
+ fast: FastModule;
273
+ chain: ChainModule;
274
+ token: TokenModule;
275
+ param: ParamModule;
276
+ simulator: SimulatorModule;
277
+ data: DataInterface;
278
+
279
+ // 静态工具类引用
280
+ static CurveAMM: typeof CurveAMM;
281
+ static OrderUtils: typeof OrderUtils;
282
+
283
+ constructor(
284
+ connection: Connection,
285
+ programId: string | PublicKey,
286
+ options?: Fun100xSdkOptions
287
+ );
288
+
289
+ // OrderUtils 快捷方法
290
+ buildLpPairs(orders: OrderData[], direction: string, price: any, maxCount?: number): LpPair[];
291
+ buildOrderAccounts(orders: OrderData[], maxCount?: number): (string | null)[];
292
+ findPrevNext(orders: OrderData[], findOrderPda: string): FindPrevNextResult;
293
+ findOrderIndex(orders: OrderData[], targetOrderPda: string | PublicKey | null): number;
294
+ }
295
+
296
+ // ========================= 工具类导出 =========================
297
+
298
+ export declare class OrderUtils {
299
+ static buildLpPairs(orders: OrderData[], direction: string, price: any, maxCount?: number): LpPair[];
300
+ static buildOrderAccounts(orders: OrderData[], maxCount?: number): (string | null)[];
301
+ static findPrevNext(orders: OrderData[], findOrderPda: string): FindPrevNextResult;
302
+ static findOrderIndex(orders: OrderData[], targetOrderPda: string | PublicKey | null): number;
303
+ static validateOrdersFormat(orders: OrderData[], throwOnError?: boolean): boolean | ValidationResult;
304
+ }
305
+
306
+ export declare class CurveAMM {
307
+ static readonly INITIAL_SOL_RESERVE_DECIMAL: any;
308
+ static readonly INITIAL_TOKEN_RESERVE_DECIMAL: any;
309
+ static readonly INITIAL_K_DECIMAL: any;
310
+ static readonly INITIAL_MIN_PRICE_DECIMAL: any;
311
+ static readonly PRICE_PRECISION_FACTOR_DECIMAL: any;
312
+ static readonly TOKEN_PRECISION_FACTOR_DECIMAL: any;
313
+ static readonly SOL_PRECISION_FACTOR_DECIMAL: any;
314
+ static readonly MAX_U128_PRICE: bigint;
315
+ static readonly MIN_U128_PRICE: bigint;
316
+
317
+ // Price conversion methods
318
+ static u128ToDecimal(price: bigint | string | number): any;
319
+ static decimalToU128(price: any): bigint | null;
320
+ static decimalToU128Ceil(price: any): bigint | null;
321
+ static u64ToDecimal(price: bigint | string | number): any;
322
+ static decimalToU64(price: any): bigint | null;
323
+ static decimalToU64Ceil(price: any): bigint | null;
324
+
325
+ // Token amount conversion methods
326
+ static tokenDecimalToU64(amount: any): bigint | null;
327
+ static tokenDecimalToU64Ceil(amount: any): bigint | null;
328
+ static u64ToTokenDecimal(amount: bigint | string | number): any;
329
+
330
+ // SOL amount conversion methods
331
+ static solDecimalToU64(amount: any): bigint | null;
332
+ static solDecimalToU64Ceil(amount: any): bigint | null;
333
+ static u64ToSolDecimal(amount: bigint | string | number): any;
334
+
335
+ // Initial price and K calculation
336
+ static calculateInitialK(): any;
337
+ static getInitialPrice(): bigint | null;
338
+
339
+ // Custom pool parameters calculation (动态流动池)
340
+ static calculateK(initialVirtualSol: any, initialVirtualToken: any): any;
341
+ static getInitialPriceWithParams(initialVirtualSol: any, initialVirtualToken: any): bigint | null;
342
+
343
+ // AMM calculation methods (default pool parameters)
344
+ static calculateReservesByPrice(price: any, k: any): [any, any] | null;
345
+ static buyFromPriceToPrice(startLowPrice: bigint | string | number, endHighPrice: bigint | string | number): [bigint, bigint] | null;
346
+ static sellFromPriceToPrice(startHighPrice: bigint | string | number, endLowPrice: bigint | string | number): [bigint, bigint] | null;
347
+ static buyFromPriceWithSolInput(startLowPrice: bigint | string | number, solInputAmount: bigint | string | number): [bigint, bigint] | null;
348
+ static sellFromPriceWithTokenInput(startHighPrice: bigint | string | number, tokenInputAmount: bigint | string | number): [bigint, bigint] | null;
349
+ static buyFromPriceWithTokenOutput(startLowPrice: bigint | string | number, tokenOutputAmount: bigint | string | number): [bigint, bigint] | null;
350
+ static sellFromPriceWithSolOutput(startHighPrice: bigint | string | number, solOutputAmount: bigint | string | number): [bigint, bigint] | null;
351
+
352
+ // AMM calculation methods with custom pool parameters (动态流动池)
353
+ static priceToReservesWithParams(price: any, initialVirtualSol: any, initialVirtualToken: any): [any, any] | null;
354
+ static buyFromPriceToPriceWithParams(startLowPrice: bigint | string | number, endHighPrice: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
355
+ static sellFromPriceToPriceWithParams(startHighPrice: bigint | string | number, endLowPrice: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
356
+ static buyFromPriceWithSolInputWithParams(startLowPrice: bigint | string | number, solInputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
357
+ static sellFromPriceWithTokenInputWithParams(startHighPrice: bigint | string | number, tokenInputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
358
+ static buyFromPriceWithTokenOutputWithParams(startLowPrice: bigint | string | number, tokenOutputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
359
+ static sellFromPriceWithSolOutputWithParams(startHighPrice: bigint | string | number, solOutputAmount: bigint | string | number, initialVirtualSol: any, initialVirtualToken: any): [bigint, bigint] | null;
360
+
361
+ // Fee and price display methods
362
+ static calculateAmountAfterFee(amount: bigint | string | number, fee: number): bigint | null;
363
+ static formatPriceForDisplay(price: bigint | string | number, decimalPlaces?: number): string;
364
+ static createPriceDisplayString(price: bigint | string | number, decimalPlaces?: number): string;
365
+ static calculatePoolPrice(lpTokenReserve: bigint | string | number | BN, lpSolReserve: bigint | string | number | BN): string | null;
366
+ }
367
+
368
+ // ========================= 常量和函数导出 =========================
369
+
370
+ export declare const FUN100X_PROGRAM_ID: PublicKey;
371
+
372
+ export declare function getProgramId(network?: NetworkType): PublicKey;
373
+
374
+ export declare function getDefaultOptions(networkName?: 'MAINNET' | 'DEVNET' | 'LOCALNET'): NetworkConfig;
375
+
376
+ // ========================= 模块类导出 =========================
377
+
378
+ export declare class TradingModule implements TradingModule {}
379
+ export declare class FastModule implements FastModule {}
380
+ export declare class ChainModule implements ChainModule {}
381
+ export declare class TokenModule implements TokenModule {}
382
+ export declare class ParamModule implements ParamModule {}
383
+ export declare class SimulatorModule implements SimulatorModule {}
384
+
385
+ // 默认导出
386
+ export default Fun100xSdk;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * 100x SDK default configuration constants
3
+ */
4
+
5
+ // Default network configuration
6
+ const DEFAULT_NETWORKS = {
7
+ MAINNET: {
8
+ name: 'mainnet-beta',
9
+ network: 'mainnet',
10
+ programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
11
+ defaultDataSource: 'fast',
12
+ solanaEndpoint: 'https://solana-rpc.pinpet.fun',
13
+ fastApiUrl: 'https://api.pinpet.fun/',
14
+ feeRecipient: 'CmDe8JRAPJ7QpZNCb4ArVEyzyxYoCNL7WZw5qXLePULn',
15
+ baseFeeRecipient: '2xhAfEfnH8wg7ZGujSijJi4Zt4ge1ZuwMypo7etntgXA',
16
+ paramsAccount: 'CJSn3n4MVCg4qWQ7qb2nxzosYwfcRyBvmwhtM77ugu1V'
17
+ },
18
+ DEVNET: {
19
+ name: 'devnet',
20
+ network: 'localnet',
21
+ programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
22
+ defaultDataSource: 'fast',
23
+ solanaEndpoint: 'https://lu-ura5lv-fast-devnet.helius-rpc.com',
24
+ fastApiUrl: 'https://devtestapi.pinpet.fun',
25
+ feeRecipient: 'GesAj2dTn2wdNcxj4x8qsqS9aNRVPBPkE76aaqg7skxu',
26
+ baseFeeRecipient: '5YHi1HsxobLiTD6NQfHJQpoPoRjMuNyXp4RroTvR6dKi',
27
+ paramsAccount: 'Ckz5CmbpyKtKmwgw7NDLzFnVACxekWqrX8i6vhCyLkqY'
28
+ },
29
+ LOCALNET: {
30
+ name: 'localnet',
31
+ network: 'localnet',
32
+ programId: 'sGecRTjTZmnqJBmLK4ZMNCzsaMrgkFfNqEcYk1GhRde',
33
+ defaultDataSource: 'fast', // 'fast' or 'chain'
34
+ solanaEndpoint: 'http://127.0.0.1:8899',
35
+ fastApiUrl: 'http://127.0.0.1:3000',
36
+ // solanaEndpoint: 'http://216.158.231.58:8899',
37
+ // fastApiUrl: 'http://216.158.231.58:3000',
38
+ feeRecipient: 'GesAj2dTn2wdNcxj4x8qsqS9aNRVPBPkE76aaqg7skxu',
39
+ baseFeeRecipient: '5YHi1HsxobLiTD6NQfHJQpoPoRjMuNyXp4RroTvR6dKi',
40
+ paramsAccount: 'FqQM2qikNcQDbzufTjURq4Eg9Wc6rLjJQYgyFdHdks1P'
41
+ }
42
+ };
43
+
44
+
45
+
46
+ // Get default configuration
47
+ function getDefaultOptions(networkName = 'LOCALNET') {
48
+ const networkConfig = DEFAULT_NETWORKS[networkName];
49
+
50
+ return {
51
+ ...networkConfig
52
+ };
53
+ }
54
+
55
+ module.exports = {
56
+ getDefaultOptions
57
+ };