four-flap-meme-sdk 1.4.18 → 1.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/sol/constants.d.ts +126 -0
  4. package/dist/sol/constants.js +145 -0
  5. package/dist/sol/dex/index.d.ts +8 -0
  6. package/dist/sol/dex/index.js +12 -0
  7. package/dist/sol/dex/meteora/client.d.ts +76 -0
  8. package/dist/sol/dex/meteora/client.js +219 -0
  9. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
  10. package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
  11. package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
  12. package/dist/sol/dex/meteora/damm-v1.js +315 -0
  13. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
  14. package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
  15. package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
  16. package/dist/sol/dex/meteora/damm-v2.js +632 -0
  17. package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
  18. package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
  19. package/dist/sol/dex/meteora/dbc.d.ts +192 -0
  20. package/dist/sol/dex/meteora/dbc.js +619 -0
  21. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
  22. package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
  23. package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
  24. package/dist/sol/dex/meteora/dlmm.js +671 -0
  25. package/dist/sol/dex/meteora/index.d.ts +25 -0
  26. package/dist/sol/dex/meteora/index.js +65 -0
  27. package/dist/sol/dex/meteora/types.d.ts +787 -0
  28. package/dist/sol/dex/meteora/types.js +110 -0
  29. package/dist/sol/dex/orca/index.d.ts +10 -0
  30. package/dist/sol/dex/orca/index.js +16 -0
  31. package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
  32. package/dist/sol/dex/orca/orca-bundle.js +173 -0
  33. package/dist/sol/dex/orca/orca.d.ts +65 -0
  34. package/dist/sol/dex/orca/orca.js +474 -0
  35. package/dist/sol/dex/orca/types.d.ts +263 -0
  36. package/dist/sol/dex/orca/types.js +38 -0
  37. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
  38. package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
  39. package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
  40. package/dist/sol/dex/orca/wavebreak-types.js +23 -0
  41. package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
  42. package/dist/sol/dex/orca/wavebreak.js +497 -0
  43. package/dist/sol/dex/pump/index.d.ts +9 -0
  44. package/dist/sol/dex/pump/index.js +14 -0
  45. package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
  46. package/dist/sol/dex/pump/pump-bundle.js +383 -0
  47. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
  48. package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
  49. package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
  50. package/dist/sol/dex/pump/pump-swap.js +199 -0
  51. package/dist/sol/dex/pump/pump.d.ts +35 -0
  52. package/dist/sol/dex/pump/pump.js +352 -0
  53. package/dist/sol/dex/pump/types.d.ts +215 -0
  54. package/dist/sol/dex/pump/types.js +5 -0
  55. package/dist/sol/dex/raydium/index.d.ts +8 -0
  56. package/dist/sol/dex/raydium/index.js +12 -0
  57. package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
  58. package/dist/sol/dex/raydium/launchlab.js +210 -0
  59. package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
  60. package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
  61. package/dist/sol/dex/raydium/raydium.d.ts +40 -0
  62. package/dist/sol/dex/raydium/raydium.js +366 -0
  63. package/dist/sol/dex/raydium/types.d.ts +240 -0
  64. package/dist/sol/dex/raydium/types.js +5 -0
  65. package/dist/sol/index.d.ts +10 -0
  66. package/dist/sol/index.js +16 -0
  67. package/dist/sol/jito/bundle.d.ts +90 -0
  68. package/dist/sol/jito/bundle.js +263 -0
  69. package/dist/sol/jito/index.d.ts +7 -0
  70. package/dist/sol/jito/index.js +7 -0
  71. package/dist/sol/jito/tip.d.ts +51 -0
  72. package/dist/sol/jito/tip.js +83 -0
  73. package/dist/sol/jito/types.d.ts +100 -0
  74. package/dist/sol/jito/types.js +5 -0
  75. package/dist/sol/token/create-complete.d.ts +115 -0
  76. package/dist/sol/token/create-complete.js +235 -0
  77. package/dist/sol/token/create-token.d.ts +57 -0
  78. package/dist/sol/token/create-token.js +230 -0
  79. package/dist/sol/token/index.d.ts +9 -0
  80. package/dist/sol/token/index.js +14 -0
  81. package/dist/sol/token/metadata-upload.d.ts +86 -0
  82. package/dist/sol/token/metadata-upload.js +173 -0
  83. package/dist/sol/token/metadata.d.ts +92 -0
  84. package/dist/sol/token/metadata.js +274 -0
  85. package/dist/sol/token/types.d.ts +153 -0
  86. package/dist/sol/token/types.js +5 -0
  87. package/dist/sol/types.d.ts +176 -0
  88. package/dist/sol/types.js +7 -0
  89. package/dist/sol/utils/balance.d.ts +160 -0
  90. package/dist/sol/utils/balance.js +638 -0
  91. package/dist/sol/utils/connection.d.ts +78 -0
  92. package/dist/sol/utils/connection.js +168 -0
  93. package/dist/sol/utils/index.d.ts +9 -0
  94. package/dist/sol/utils/index.js +9 -0
  95. package/dist/sol/utils/lp-inspect.d.ts +129 -0
  96. package/dist/sol/utils/lp-inspect.js +900 -0
  97. package/dist/sol/utils/transfer.d.ts +125 -0
  98. package/dist/sol/utils/transfer.js +220 -0
  99. package/dist/sol/utils/wallet.d.ts +107 -0
  100. package/dist/sol/utils/wallet.js +210 -0
  101. package/package.json +38 -3
  102. package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
  103. package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as Abis from './abis/index.js';
2
+ export * as Sol from './sol/index.js';
2
3
  export { ADDRESSES, CHAIN } from './utils/constants.js';
3
4
  export { isExclusiveOnChain, isExclusiveOffChain } from './utils/mpcExclusive.js';
4
5
  export { ensureSellApprovalV1, checkSellApprovalV1, ensureSellApprovalV2, checkSellApprovalV2, ensureSellApproval, checkSellApproval, ensureFlapSellApproval, checkFlapSellApproval, ensureFlapSellApprovalBatch, checkFlapSellApprovalBatch, checkAllowance, approveToken, checkAllowanceBatch, approveTokenBatch, checkAllowanceRaw, approveTokenRaw, checkAllowanceBatchRaw, approveTokenBatchRaw, type EnsureAllowanceBatchItemResult, type ApproveTokenBatchParams, type ApproveTokenBatchRawParams, type ApproveTokenBatchResult, type ApproveTokenBatchSignResult } from './utils/erc20.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as Abis from './abis/index.js';
2
+ export * as Sol from './sol/index.js';
2
3
  export { ADDRESSES, CHAIN } from './utils/constants.js';
3
4
  export { isExclusiveOnChain, isExclusiveOffChain } from './utils/mpcExclusive.js';
4
5
  export {
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Solana SDK 常量配置
3
+ * @module sol/constants
4
+ */
5
+ /**
6
+ * Jito 配置
7
+ *
8
+ * 注意:BLOCK_ENGINE_URL 需要由前端传入,不在 SDK 中写死
9
+ */
10
+ export declare const JITO_CONFIG: {
11
+ /** Tip 账户列表(随机选择一个)- 这些是 Jito 官方账户,固定不变 */
12
+ readonly TIP_ACCOUNTS: readonly ["96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5", "HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U", "Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY", "ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49", "DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh", "ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt", "DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL", "3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"];
13
+ /** 最小 Tip(lamports) */
14
+ readonly MIN_TIP_LAMPORTS: 1000;
15
+ /** 默认 Tip(lamports)- 0.00001 SOL */
16
+ readonly DEFAULT_TIP_LAMPORTS: 10000;
17
+ };
18
+ /**
19
+ * Solana 系统程序地址
20
+ */
21
+ export declare const SYSTEM_PROGRAMS: {
22
+ /** Token Program */
23
+ readonly TOKEN_PROGRAM: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
24
+ /** Token-2022 Program */
25
+ readonly TOKEN_2022_PROGRAM: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
26
+ /** Associated Token Account Program */
27
+ readonly ATA_PROGRAM: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
28
+ /** Metaplex Token Metadata Program */
29
+ readonly METADATA_PROGRAM: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
30
+ /** System Program */
31
+ readonly SYSTEM_PROGRAM: "11111111111111111111111111111111";
32
+ /** Rent Sysvar */
33
+ readonly RENT_SYSVAR: "SysvarRent111111111111111111111111111111111";
34
+ };
35
+ /**
36
+ * Pump.fun 程序地址
37
+ */
38
+ export declare const PUMP_PROGRAMS: {
39
+ /** Pump Program ID */
40
+ readonly PUMP_PROGRAM: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
41
+ /** Pump Swap Program ID */
42
+ readonly PUMP_SWAP_PROGRAM: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
43
+ /** Global Config */
44
+ readonly GLOBAL_CONFIG: "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf";
45
+ };
46
+ /**
47
+ * Raydium 程序地址
48
+ */
49
+ export declare const RAYDIUM_PROGRAMS: {
50
+ /** AMM Program ID */
51
+ readonly AMM_PROGRAM: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
52
+ /** CLMM Program ID */
53
+ readonly CLMM_PROGRAM: "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
54
+ /** LaunchLab Program ID */
55
+ readonly LAUNCHLAB_PROGRAM: "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj";
56
+ };
57
+ /**
58
+ * Orca 程序地址
59
+ */
60
+ export declare const ORCA_PROGRAMS: {
61
+ /** Whirlpool Program ID */
62
+ readonly WHIRLPOOL_PROGRAM: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
63
+ };
64
+ /**
65
+ * Meteora 程序地址
66
+ */
67
+ export declare const METEORA_PROGRAMS: {
68
+ /** DLMM Program ID */
69
+ readonly DLMM_PROGRAM: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
70
+ /** DAMM v2 Program ID */
71
+ readonly DAMM_V2_PROGRAM: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
72
+ /** DBC Program ID */
73
+ readonly DBC_PROGRAM: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN";
74
+ };
75
+ /**
76
+ * 常用代币地址
77
+ */
78
+ export declare const TOKENS: {
79
+ /** Wrapped SOL */
80
+ readonly SOL: "So11111111111111111111111111111111111111112";
81
+ /** USDC */
82
+ readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
83
+ /** USDT */
84
+ readonly USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
85
+ };
86
+ /**
87
+ * 交易默认配置
88
+ */
89
+ export declare const TX_CONFIG: {
90
+ /** 默认滑点 1% */
91
+ readonly DEFAULT_SLIPPAGE: 1;
92
+ /** 最大滑点 50% */
93
+ readonly MAX_SLIPPAGE: 50;
94
+ /** 计算单元限制 */
95
+ readonly COMPUTE_UNIT_LIMIT: 200000;
96
+ /** 计算单元价格(microlamports) */
97
+ readonly COMPUTE_UNIT_PRICE: 50000;
98
+ /** 确认超时(毫秒) */
99
+ readonly CONFIRMATION_TIMEOUT: 60000;
100
+ /** 默认 commitment */
101
+ readonly DEFAULT_COMMITMENT: "confirmed";
102
+ };
103
+ /**
104
+ * 账户大小(用于计算租金)
105
+ */
106
+ export declare const ACCOUNT_SIZE: {
107
+ /** Mint 账户大小 */
108
+ readonly MINT: 82;
109
+ /** Token 账户大小 */
110
+ readonly TOKEN_ACCOUNT: 165;
111
+ /** Metadata 账户大小(近似值) */
112
+ readonly METADATA: 679;
113
+ };
114
+ /**
115
+ * SOL 单位换算
116
+ */
117
+ export declare const SOL_DECIMALS = 9;
118
+ export declare const LAMPORTS_PER_SOL = 1000000000;
119
+ /**
120
+ * 将 SOL 转换为 lamports
121
+ */
122
+ export declare function solToLamports(sol: number): bigint;
123
+ /**
124
+ * 将 lamports 转换为 SOL
125
+ */
126
+ export declare function lamportsToSol(lamports: bigint): number;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Solana SDK 常量配置
3
+ * @module sol/constants
4
+ */
5
+ // ==================== Jito Bundle 配置 ====================
6
+ /**
7
+ * Jito 配置
8
+ *
9
+ * 注意:BLOCK_ENGINE_URL 需要由前端传入,不在 SDK 中写死
10
+ */
11
+ export const JITO_CONFIG = {
12
+ /** Tip 账户列表(随机选择一个)- 这些是 Jito 官方账户,固定不变 */
13
+ TIP_ACCOUNTS: [
14
+ '96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5',
15
+ 'HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U',
16
+ 'Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY',
17
+ 'ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49',
18
+ 'DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh',
19
+ 'ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt',
20
+ 'DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL',
21
+ '3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT',
22
+ ],
23
+ /** 最小 Tip(lamports) */
24
+ MIN_TIP_LAMPORTS: 1000,
25
+ /** 默认 Tip(lamports)- 0.00001 SOL */
26
+ DEFAULT_TIP_LAMPORTS: 10000,
27
+ };
28
+ // ==================== 程序地址 ====================
29
+ /**
30
+ * Solana 系统程序地址
31
+ */
32
+ export const SYSTEM_PROGRAMS = {
33
+ /** Token Program */
34
+ TOKEN_PROGRAM: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
35
+ /** Token-2022 Program */
36
+ TOKEN_2022_PROGRAM: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
37
+ /** Associated Token Account Program */
38
+ ATA_PROGRAM: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
39
+ /** Metaplex Token Metadata Program */
40
+ METADATA_PROGRAM: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
41
+ /** System Program */
42
+ SYSTEM_PROGRAM: '11111111111111111111111111111111',
43
+ /** Rent Sysvar */
44
+ RENT_SYSVAR: 'SysvarRent111111111111111111111111111111111',
45
+ };
46
+ /**
47
+ * Pump.fun 程序地址
48
+ */
49
+ export const PUMP_PROGRAMS = {
50
+ /** Pump Program ID */
51
+ PUMP_PROGRAM: '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P',
52
+ /** Pump Swap Program ID */
53
+ PUMP_SWAP_PROGRAM: 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA',
54
+ /** Global Config */
55
+ GLOBAL_CONFIG: '4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf',
56
+ };
57
+ /**
58
+ * Raydium 程序地址
59
+ */
60
+ export const RAYDIUM_PROGRAMS = {
61
+ /** AMM Program ID */
62
+ AMM_PROGRAM: '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8',
63
+ /** CLMM Program ID */
64
+ CLMM_PROGRAM: 'CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK',
65
+ /** LaunchLab Program ID */
66
+ LAUNCHLAB_PROGRAM: 'LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj',
67
+ };
68
+ /**
69
+ * Orca 程序地址
70
+ */
71
+ export const ORCA_PROGRAMS = {
72
+ /** Whirlpool Program ID */
73
+ WHIRLPOOL_PROGRAM: 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc',
74
+ };
75
+ /**
76
+ * Meteora 程序地址
77
+ */
78
+ export const METEORA_PROGRAMS = {
79
+ /** DLMM Program ID */
80
+ DLMM_PROGRAM: 'LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo',
81
+ /** DAMM v2 Program ID */
82
+ DAMM_V2_PROGRAM: 'cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG',
83
+ /** DBC Program ID */
84
+ DBC_PROGRAM: 'dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN',
85
+ };
86
+ // ==================== 常用代币地址 ====================
87
+ /**
88
+ * 常用代币地址
89
+ */
90
+ export const TOKENS = {
91
+ /** Wrapped SOL */
92
+ SOL: 'So11111111111111111111111111111111111111112',
93
+ /** USDC */
94
+ USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
95
+ /** USDT */
96
+ USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
97
+ };
98
+ // ==================== 交易配置 ====================
99
+ /**
100
+ * 交易默认配置
101
+ */
102
+ export const TX_CONFIG = {
103
+ /** 默认滑点 1% */
104
+ DEFAULT_SLIPPAGE: 1,
105
+ /** 最大滑点 50% */
106
+ MAX_SLIPPAGE: 50,
107
+ /** 计算单元限制 */
108
+ COMPUTE_UNIT_LIMIT: 200000,
109
+ /** 计算单元价格(microlamports) */
110
+ COMPUTE_UNIT_PRICE: 50000,
111
+ /** 确认超时(毫秒) */
112
+ CONFIRMATION_TIMEOUT: 60000,
113
+ /** 默认 commitment */
114
+ DEFAULT_COMMITMENT: 'confirmed',
115
+ };
116
+ // ==================== 账户大小 ====================
117
+ /**
118
+ * 账户大小(用于计算租金)
119
+ */
120
+ export const ACCOUNT_SIZE = {
121
+ /** Mint 账户大小 */
122
+ MINT: 82,
123
+ /** Token 账户大小 */
124
+ TOKEN_ACCOUNT: 165,
125
+ /** Metadata 账户大小(近似值) */
126
+ METADATA: 679,
127
+ };
128
+ // ==================== 单位换算 ====================
129
+ /**
130
+ * SOL 单位换算
131
+ */
132
+ export const SOL_DECIMALS = 9;
133
+ export const LAMPORTS_PER_SOL = 1000000000;
134
+ /**
135
+ * 将 SOL 转换为 lamports
136
+ */
137
+ export function solToLamports(sol) {
138
+ return BigInt(Math.floor(sol * LAMPORTS_PER_SOL));
139
+ }
140
+ /**
141
+ * 将 lamports 转换为 SOL
142
+ */
143
+ export function lamportsToSol(lamports) {
144
+ return Number(lamports) / LAMPORTS_PER_SOL;
145
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * DEX 模块导出
3
+ * @module sol/dex
4
+ */
5
+ export * from './pump/index.js';
6
+ export * from './raydium/index.js';
7
+ export * from './orca/index.js';
8
+ export * from './meteora/index.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * DEX 模块导出
3
+ * @module sol/dex
4
+ */
5
+ // Pump.fun
6
+ export * from './pump/index.js';
7
+ // Raydium
8
+ export * from './raydium/index.js';
9
+ // Orca
10
+ export * from './orca/index.js';
11
+ // Meteora
12
+ export * from './meteora/index.js';
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Meteora SDK 客户端管理器
3
+ *
4
+ * 统一管理 RPC 连接和 SDK 实例,避免重复实例化
5
+ */
6
+ import { Connection } from '@solana/web3.js';
7
+ import { CpAmm } from '@meteora-ag/cp-amm-sdk';
8
+ import { DynamicBondingCurveClient } from '@meteora-ag/dynamic-bonding-curve-sdk';
9
+ /**
10
+ * 获取连接
11
+ * @param connection 可选的自定义连接
12
+ * @throws Error 如果没有传入连接且未设置默认连接
13
+ */
14
+ export declare function getConnection(connection?: Connection): Connection;
15
+ /**
16
+ * 设置默认连接
17
+ * @param connection 新的连接实例
18
+ */
19
+ export declare function setDefaultConnection(connection: Connection): void;
20
+ /**
21
+ * 重置默认连接
22
+ */
23
+ export declare function resetDefaultConnection(): void;
24
+ /**
25
+ * 获取或创建 DLMM 池实例
26
+ * @param poolAddress 池地址
27
+ * @param connection 可选连接
28
+ * @param forceRefresh 强制刷新缓存
29
+ */
30
+ export declare function getDlmmPool(poolAddress: string, connection?: Connection, forceRefresh?: boolean): Promise<any>;
31
+ /**
32
+ * 获取所有 DLMM 池列表
33
+ * @param connection 可选连接
34
+ */
35
+ export declare function getAllDlmmPools(connection?: Connection): Promise<any[]>;
36
+ /**
37
+ * 清除 DLMM 池缓存
38
+ * @param poolAddress 可选,指定池地址;不传则清除全部
39
+ */
40
+ export declare function clearDlmmCache(poolAddress?: string): void;
41
+ /**
42
+ * 获取或创建 DBC 客户端
43
+ * @param connection 可选连接
44
+ */
45
+ export declare function getDbcClient(connection?: Connection): DynamicBondingCurveClient;
46
+ /**
47
+ * 重置 DBC 客户端
48
+ */
49
+ export declare function resetDbcClient(): void;
50
+ /**
51
+ * 获取或创建 DAMM v1 池实例
52
+ * @param poolAddress 池地址
53
+ * @param connection 可选连接
54
+ * @param forceRefresh 强制刷新缓存
55
+ */
56
+ export declare function getDammV1Pool(poolAddress: string, connection?: Connection, forceRefresh?: boolean): Promise<any>;
57
+ /**
58
+ * 清除 DAMM v1 池缓存
59
+ * @param poolAddress 可选,指定池地址;不传则清除全部
60
+ */
61
+ export declare function clearDammV1Cache(poolAddress?: string): void;
62
+ /**
63
+ * 获取或创建 DAMM v2 (CpAmm) 客户端
64
+ * @param connection 可选连接
65
+ */
66
+ export declare function getCpAmmClient(connection?: Connection): CpAmm;
67
+ /**
68
+ * 重置 DAMM v2 客户端
69
+ */
70
+ export declare function resetCpAmmClient(): void;
71
+ /**
72
+ * 清除所有 Meteora 缓存
73
+ */
74
+ export declare function clearAllMeteoraCache(): void;
75
+ export declare function setCacheTtl(ttlMs: number): void;
76
+ export declare function getCacheTtl(): number;
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Meteora SDK 客户端管理器
3
+ *
4
+ * 统一管理 RPC 连接和 SDK 实例,避免重复实例化
5
+ */
6
+ import { PublicKey } from '@solana/web3.js';
7
+ // 不再导入 createConnection,强制使用者传入连接
8
+ // SDK 导入 - 使用类型断言绕过 TypeScript 类型检查
9
+ import DLMMModule from '@meteora-ag/dlmm';
10
+ import AmmImplModule from '@meteora-ag/dynamic-amm-sdk';
11
+ import { CpAmm } from '@meteora-ag/cp-amm-sdk';
12
+ import { DynamicBondingCurveClient } from '@meteora-ag/dynamic-bonding-curve-sdk';
13
+ const DLMM = DLMMModule;
14
+ const AmmImpl = AmmImplModule;
15
+ // ============================================================================
16
+ // 连接管理
17
+ // ============================================================================
18
+ /** 默认连接实例(必须通过 setDefaultConnection 设置) */
19
+ let defaultConnection = null;
20
+ /**
21
+ * 获取连接
22
+ * @param connection 可选的自定义连接
23
+ * @throws Error 如果没有传入连接且未设置默认连接
24
+ */
25
+ export function getConnection(connection) {
26
+ if (connection) {
27
+ return connection;
28
+ }
29
+ if (!defaultConnection) {
30
+ throw new Error('Connection is required. Either pass a connection parameter or call setDefaultConnection() first with user-configured RPC.');
31
+ }
32
+ return defaultConnection;
33
+ }
34
+ /**
35
+ * 设置默认连接
36
+ * @param connection 新的连接实例
37
+ */
38
+ export function setDefaultConnection(connection) {
39
+ defaultConnection = connection;
40
+ }
41
+ /**
42
+ * 重置默认连接
43
+ */
44
+ export function resetDefaultConnection() {
45
+ defaultConnection = null;
46
+ }
47
+ // ============================================================================
48
+ // DLMM 实例缓存
49
+ // ============================================================================
50
+ /** DLMM 池实例缓存 */
51
+ const dlmmPoolCache = new Map();
52
+ /** 缓存过期时间 (毫秒) - 默认 30 秒 */
53
+ const CACHE_TTL = 30 * 1000;
54
+ /**
55
+ * 获取或创建 DLMM 池实例
56
+ * @param poolAddress 池地址
57
+ * @param connection 可选连接
58
+ * @param forceRefresh 强制刷新缓存
59
+ */
60
+ export async function getDlmmPool(poolAddress, connection, forceRefresh = false) {
61
+ const conn = getConnection(connection);
62
+ const cacheKey = poolAddress;
63
+ // 检查缓存
64
+ if (!forceRefresh) {
65
+ const cached = dlmmPoolCache.get(cacheKey);
66
+ if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
67
+ return cached.instance;
68
+ }
69
+ }
70
+ // 创建新实例
71
+ const instance = await DLMM.create(conn, new PublicKey(poolAddress));
72
+ // 存入缓存
73
+ dlmmPoolCache.set(cacheKey, {
74
+ instance,
75
+ timestamp: Date.now(),
76
+ });
77
+ return instance;
78
+ }
79
+ /**
80
+ * 获取所有 DLMM 池列表
81
+ * @param connection 可选连接
82
+ */
83
+ export async function getAllDlmmPools(connection) {
84
+ const conn = getConnection(connection);
85
+ return DLMM.getLbPairs(conn);
86
+ }
87
+ /**
88
+ * 清除 DLMM 池缓存
89
+ * @param poolAddress 可选,指定池地址;不传则清除全部
90
+ */
91
+ export function clearDlmmCache(poolAddress) {
92
+ if (poolAddress) {
93
+ dlmmPoolCache.delete(poolAddress);
94
+ }
95
+ else {
96
+ dlmmPoolCache.clear();
97
+ }
98
+ }
99
+ // ============================================================================
100
+ // DBC 客户端管理
101
+ // ============================================================================
102
+ /** DBC 客户端实例缓存 */
103
+ let dbcClient = null;
104
+ let dbcClientConnection = null;
105
+ /**
106
+ * 获取或创建 DBC 客户端
107
+ * @param connection 可选连接
108
+ */
109
+ export function getDbcClient(connection) {
110
+ const conn = getConnection(connection);
111
+ // 如果连接相同,复用现有客户端
112
+ if (dbcClient && dbcClientConnection === conn) {
113
+ return dbcClient;
114
+ }
115
+ // 创建新客户端
116
+ dbcClient = DynamicBondingCurveClient.create(conn, 'confirmed');
117
+ dbcClientConnection = conn;
118
+ return dbcClient;
119
+ }
120
+ /**
121
+ * 重置 DBC 客户端
122
+ */
123
+ export function resetDbcClient() {
124
+ dbcClient = null;
125
+ dbcClientConnection = null;
126
+ }
127
+ // ============================================================================
128
+ // DAMM v1 实例缓存
129
+ // ============================================================================
130
+ /** DAMM v1 池实例缓存 */
131
+ const dammV1PoolCache = new Map();
132
+ /**
133
+ * 获取或创建 DAMM v1 池实例
134
+ * @param poolAddress 池地址
135
+ * @param connection 可选连接
136
+ * @param forceRefresh 强制刷新缓存
137
+ */
138
+ export async function getDammV1Pool(poolAddress, connection, forceRefresh = false) {
139
+ const conn = getConnection(connection);
140
+ const cacheKey = poolAddress;
141
+ // 检查缓存
142
+ if (!forceRefresh) {
143
+ const cached = dammV1PoolCache.get(cacheKey);
144
+ if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
145
+ return cached.instance;
146
+ }
147
+ }
148
+ // 创建新实例
149
+ const instance = await AmmImpl.create(conn, new PublicKey(poolAddress));
150
+ // 存入缓存
151
+ dammV1PoolCache.set(cacheKey, {
152
+ instance,
153
+ timestamp: Date.now(),
154
+ });
155
+ return instance;
156
+ }
157
+ /**
158
+ * 清除 DAMM v1 池缓存
159
+ * @param poolAddress 可选,指定池地址;不传则清除全部
160
+ */
161
+ export function clearDammV1Cache(poolAddress) {
162
+ if (poolAddress) {
163
+ dammV1PoolCache.delete(poolAddress);
164
+ }
165
+ else {
166
+ dammV1PoolCache.clear();
167
+ }
168
+ }
169
+ // ============================================================================
170
+ // DAMM v2 客户端管理
171
+ // ============================================================================
172
+ /** DAMM v2 客户端实例缓存 */
173
+ let cpAmmClient = null;
174
+ let cpAmmClientConnection = null;
175
+ /**
176
+ * 获取或创建 DAMM v2 (CpAmm) 客户端
177
+ * @param connection 可选连接
178
+ */
179
+ export function getCpAmmClient(connection) {
180
+ const conn = getConnection(connection);
181
+ // 如果连接相同,复用现有客户端
182
+ if (cpAmmClient && cpAmmClientConnection === conn) {
183
+ return cpAmmClient;
184
+ }
185
+ // 创建新客户端
186
+ cpAmmClient = new CpAmm(conn);
187
+ cpAmmClientConnection = conn;
188
+ return cpAmmClient;
189
+ }
190
+ /**
191
+ * 重置 DAMM v2 客户端
192
+ */
193
+ export function resetCpAmmClient() {
194
+ cpAmmClient = null;
195
+ cpAmmClientConnection = null;
196
+ }
197
+ // ============================================================================
198
+ // 全局缓存管理
199
+ // ============================================================================
200
+ /**
201
+ * 清除所有 Meteora 缓存
202
+ */
203
+ export function clearAllMeteoraCache() {
204
+ clearDlmmCache();
205
+ clearDammV1Cache();
206
+ resetDbcClient();
207
+ resetCpAmmClient();
208
+ }
209
+ /**
210
+ * 设置缓存 TTL (毫秒)
211
+ * 注意: 这会影响新创建的缓存项,不会影响已存在的
212
+ */
213
+ let cacheTtl = CACHE_TTL;
214
+ export function setCacheTtl(ttlMs) {
215
+ cacheTtl = ttlMs;
216
+ }
217
+ export function getCacheTtl() {
218
+ return cacheTtl;
219
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Meteora DAMM v1 Bundle 批量交易
3
+ *
4
+ * 支持 Jito Bundle 的批量买卖
5
+ */
6
+ import { Connection, Keypair } from '@solana/web3.js';
7
+ import BN from 'bn.js';
8
+ import type { MeteoraBundleSignedResult } from './types.js';
9
+ /**
10
+ * DAMM v1 Bundle Swap 参数
11
+ */
12
+ export interface DammV1BundleSwapParams {
13
+ /** 池地址 */
14
+ poolAddress: string;
15
+ /** 输入代币地址 */
16
+ inputMint: string;
17
+ /** 输出代币地址 */
18
+ outputMint: string;
19
+ /** 交易列表 */
20
+ trades: {
21
+ wallet: Keypair;
22
+ amountIn: BN;
23
+ minAmountOut?: BN;
24
+ }[];
25
+ /** 滑点 (bps) */
26
+ slippageBps?: number;
27
+ /** Jito 小费 */
28
+ jitoTipLamports?: number;
29
+ }
30
+ /**
31
+ * 签名 DAMM v1 Bundle 批量买入交易
32
+ *
33
+ * @param params Bundle 参数
34
+ * @param connection 可选连接
35
+ */
36
+ export declare function signDammV1BundleBuy(params: DammV1BundleSwapParams, connection?: Connection): Promise<MeteoraBundleSignedResult>;
37
+ /**
38
+ * 签名 DAMM v1 Bundle 批量卖出交易
39
+ *
40
+ * @param params Bundle 参数
41
+ * @param connection 可选连接
42
+ */
43
+ export declare function signDammV1BundleSell(params: DammV1BundleSwapParams, connection?: Connection): Promise<MeteoraBundleSignedResult>;
44
+ /**
45
+ * 签名 DAMM v1 Bundle 通用 Swap 交易
46
+ *
47
+ * @param params Bundle 参数
48
+ * @param isBuy 是否买入 (true = 买入, false = 卖出)
49
+ * @param connection 可选连接
50
+ */
51
+ export declare function signDammV1BundleSwap(params: DammV1BundleSwapParams, isBuy: boolean, connection?: Connection): Promise<MeteoraBundleSignedResult>;
52
+ /**
53
+ * 将 Bundle 结果转换为后端 API 请求格式
54
+ */
55
+ export declare function toDammV1BundleApiRequest(result: MeteoraBundleSignedResult): {
56
+ transactions: string[];
57
+ type: string;
58
+ poolAddress: string;
59
+ tradeCount: number;
60
+ jitoTipLamports: number;
61
+ };