four-flap-meme-sdk 1.5.55 → 1.5.56

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 (150) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -1
  3. package/dist/sol/constants.d.ts +150 -0
  4. package/dist/sol/constants.js +188 -0
  5. package/dist/sol/dex/blockrazor/client.d.ts +51 -0
  6. package/dist/sol/dex/blockrazor/client.js +96 -0
  7. package/dist/sol/dex/blockrazor/constants.d.ts +34 -0
  8. package/dist/sol/dex/blockrazor/constants.js +55 -0
  9. package/dist/sol/dex/blockrazor/geyser.d.ts +128 -0
  10. package/dist/sol/dex/blockrazor/geyser.js +530 -0
  11. package/dist/sol/dex/blockrazor/index.d.ts +18 -0
  12. package/dist/sol/dex/blockrazor/index.js +23 -0
  13. package/dist/sol/dex/blockrazor/send.d.ts +135 -0
  14. package/dist/sol/dex/blockrazor/send.js +254 -0
  15. package/dist/sol/dex/blockrazor/types.d.ts +191 -0
  16. package/dist/sol/dex/blockrazor/types.js +5 -0
  17. package/dist/sol/dex/index.d.ts +10 -0
  18. package/dist/sol/dex/index.js +16 -0
  19. package/dist/sol/dex/jup/client.d.ts +33 -0
  20. package/dist/sol/dex/jup/client.js +110 -0
  21. package/dist/sol/dex/jup/index.d.ts +16 -0
  22. package/dist/sol/dex/jup/index.js +148 -0
  23. package/dist/sol/dex/jup/legacy.d.ts +623 -0
  24. package/dist/sol/dex/jup/legacy.js +416 -0
  25. package/dist/sol/dex/jup/lend.d.ts +640 -0
  26. package/dist/sol/dex/jup/lend.js +603 -0
  27. package/dist/sol/dex/jup/portfolio.d.ts +362 -0
  28. package/dist/sol/dex/jup/portfolio.js +367 -0
  29. package/dist/sol/dex/jup/price.d.ts +173 -0
  30. package/dist/sol/dex/jup/price.js +220 -0
  31. package/dist/sol/dex/jup/recurring.d.ts +437 -0
  32. package/dist/sol/dex/jup/recurring.js +320 -0
  33. package/dist/sol/dex/jup/send.d.ts +282 -0
  34. package/dist/sol/dex/jup/send.js +295 -0
  35. package/dist/sol/dex/jup/studio.d.ts +457 -0
  36. package/dist/sol/dex/jup/studio.js +488 -0
  37. package/dist/sol/dex/jup/tokens.d.ts +767 -0
  38. package/dist/sol/dex/jup/tokens.js +697 -0
  39. package/dist/sol/dex/jup/trigger.d.ts +511 -0
  40. package/dist/sol/dex/jup/trigger.js +397 -0
  41. package/dist/sol/dex/jup/types.d.ts +433 -0
  42. package/dist/sol/dex/jup/types.js +5 -0
  43. package/dist/sol/dex/jup/ultra.d.ts +646 -0
  44. package/dist/sol/dex/jup/ultra.js +853 -0
  45. package/dist/sol/dex/meteora/client.d.ts +76 -0
  46. package/dist/sol/dex/meteora/client.js +219 -0
  47. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
  48. package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
  49. package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
  50. package/dist/sol/dex/meteora/damm-v1.js +315 -0
  51. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
  52. package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
  53. package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
  54. package/dist/sol/dex/meteora/damm-v2.js +632 -0
  55. package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
  56. package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
  57. package/dist/sol/dex/meteora/dbc.d.ts +192 -0
  58. package/dist/sol/dex/meteora/dbc.js +619 -0
  59. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
  60. package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
  61. package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
  62. package/dist/sol/dex/meteora/dlmm.js +671 -0
  63. package/dist/sol/dex/meteora/index.d.ts +25 -0
  64. package/dist/sol/dex/meteora/index.js +65 -0
  65. package/dist/sol/dex/meteora/types.d.ts +787 -0
  66. package/dist/sol/dex/meteora/types.js +110 -0
  67. package/dist/sol/dex/orca/index.d.ts +10 -0
  68. package/dist/sol/dex/orca/index.js +16 -0
  69. package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
  70. package/dist/sol/dex/orca/orca-bundle.js +173 -0
  71. package/dist/sol/dex/orca/orca.d.ts +65 -0
  72. package/dist/sol/dex/orca/orca.js +474 -0
  73. package/dist/sol/dex/orca/types.d.ts +263 -0
  74. package/dist/sol/dex/orca/types.js +38 -0
  75. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
  76. package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
  77. package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
  78. package/dist/sol/dex/orca/wavebreak-types.js +23 -0
  79. package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
  80. package/dist/sol/dex/orca/wavebreak.js +497 -0
  81. package/dist/sol/dex/pump/index.d.ts +9 -0
  82. package/dist/sol/dex/pump/index.js +14 -0
  83. package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
  84. package/dist/sol/dex/pump/pump-bundle.js +383 -0
  85. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
  86. package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
  87. package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
  88. package/dist/sol/dex/pump/pump-swap.js +199 -0
  89. package/dist/sol/dex/pump/pump.d.ts +35 -0
  90. package/dist/sol/dex/pump/pump.js +352 -0
  91. package/dist/sol/dex/pump/types.d.ts +215 -0
  92. package/dist/sol/dex/pump/types.js +5 -0
  93. package/dist/sol/dex/raydium/index.d.ts +8 -0
  94. package/dist/sol/dex/raydium/index.js +12 -0
  95. package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
  96. package/dist/sol/dex/raydium/launchlab.js +210 -0
  97. package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
  98. package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
  99. package/dist/sol/dex/raydium/raydium.d.ts +40 -0
  100. package/dist/sol/dex/raydium/raydium.js +366 -0
  101. package/dist/sol/dex/raydium/types.d.ts +240 -0
  102. package/dist/sol/dex/raydium/types.js +5 -0
  103. package/dist/sol/index.d.ts +11 -0
  104. package/dist/sol/index.js +18 -0
  105. package/dist/sol/jito/bundle.d.ts +90 -0
  106. package/dist/sol/jito/bundle.js +263 -0
  107. package/dist/sol/jito/index.d.ts +7 -0
  108. package/dist/sol/jito/index.js +7 -0
  109. package/dist/sol/jito/tip.d.ts +51 -0
  110. package/dist/sol/jito/tip.js +83 -0
  111. package/dist/sol/jito/types.d.ts +100 -0
  112. package/dist/sol/jito/types.js +5 -0
  113. package/dist/sol/nozomi/client.d.ts +63 -0
  114. package/dist/sol/nozomi/client.js +222 -0
  115. package/dist/sol/nozomi/index.d.ts +8 -0
  116. package/dist/sol/nozomi/index.js +8 -0
  117. package/dist/sol/nozomi/tip.d.ts +50 -0
  118. package/dist/sol/nozomi/tip.js +80 -0
  119. package/dist/sol/nozomi/types.d.ts +96 -0
  120. package/dist/sol/nozomi/types.js +5 -0
  121. package/dist/sol/token/create-complete.d.ts +115 -0
  122. package/dist/sol/token/create-complete.js +235 -0
  123. package/dist/sol/token/create-token.d.ts +57 -0
  124. package/dist/sol/token/create-token.js +230 -0
  125. package/dist/sol/token/index.d.ts +9 -0
  126. package/dist/sol/token/index.js +14 -0
  127. package/dist/sol/token/metadata-upload.d.ts +86 -0
  128. package/dist/sol/token/metadata-upload.js +173 -0
  129. package/dist/sol/token/metadata.d.ts +92 -0
  130. package/dist/sol/token/metadata.js +274 -0
  131. package/dist/sol/token/types.d.ts +153 -0
  132. package/dist/sol/token/types.js +5 -0
  133. package/dist/sol/types.d.ts +176 -0
  134. package/dist/sol/types.js +7 -0
  135. package/dist/sol/utils/balance.d.ts +160 -0
  136. package/dist/sol/utils/balance.js +638 -0
  137. package/dist/sol/utils/connection.d.ts +78 -0
  138. package/dist/sol/utils/connection.js +168 -0
  139. package/dist/sol/utils/index.d.ts +9 -0
  140. package/dist/sol/utils/index.js +9 -0
  141. package/dist/sol/utils/lp-inspect.d.ts +75 -0
  142. package/dist/sol/utils/lp-inspect.js +235 -0
  143. package/dist/sol/utils/transfer.d.ts +196 -0
  144. package/dist/sol/utils/transfer.js +307 -0
  145. package/dist/sol/utils/wallet.d.ts +107 -0
  146. package/dist/sol/utils/wallet.js +210 -0
  147. package/package.json +44 -5
  148. package/README.zh-CN.pdf +0 -0
  149. package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
  150. package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Jupiter Send API V1
3
+ * @module sol/dex/jup/send
4
+ *
5
+ * Send API 提供代币发送邀请链接功能
6
+ * 允许创建邀请链接让他人领取代币
7
+ */
8
+ import { jupGet, jupPost } from './client.js';
9
+ // ============================================================================
10
+ // Craft Send - 创建发送邀请
11
+ // ============================================================================
12
+ /**
13
+ * 创建发送邀请交易
14
+ *
15
+ * 创建一个邀请链接,让他人可以领取指定数量的代币。
16
+ *
17
+ * @param params 创建参数
18
+ * @param config Jupiter 配置
19
+ * @returns 创建响应
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { Sol } from 'four-flap-meme-sdk'
24
+ * import { Keypair } from '@solana/web3.js'
25
+ * import crypto from 'crypto'
26
+ *
27
+ * Sol.setJupiterConfig({ apiKey: 'your-api-key' })
28
+ *
29
+ * // 生成邀请码(客户端生成,安全保管)
30
+ * const inviteCode = crypto.randomBytes(32).toString('hex')
31
+ * const inviteHash = crypto.createHash('sha256').update(inviteCode).digest()
32
+ * const inviteKeypair = Keypair.fromSeed(inviteHash)
33
+ *
34
+ * // 创建发送邀请
35
+ * const result = await Sol.craftSend({
36
+ * inviteSigner: inviteKeypair.publicKey.toBase58(),
37
+ * sender: wallet.publicKey.toBase58(),
38
+ * amount: '1000000', // 1 USDC
39
+ * mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
40
+ * })
41
+ *
42
+ * console.log(`过期时间: ${new Date(parseInt(result.expiry) * 1000)}`)
43
+ * console.log(`费用: ${result.totalFeeLamports} lamports`)
44
+ *
45
+ * // 签名交易
46
+ * const tx = VersionedTransaction.deserialize(Buffer.from(result.tx, 'base64'))
47
+ * tx.sign([wallet, inviteKeypair])
48
+ *
49
+ * // 发送交易...
50
+ * // 保存 inviteCode 分享给接收者
51
+ * ```
52
+ */
53
+ export async function craftSend(params, config) {
54
+ return jupPost('/send/v1/craft-send', params, config);
55
+ }
56
+ /**
57
+ * 创建 SOL 发送邀请
58
+ *
59
+ * @param inviteSigner 邀请签名者公钥
60
+ * @param sender 发送者地址
61
+ * @param amountLamports SOL 数量 (lamports)
62
+ * @param config Jupiter 配置
63
+ * @returns 创建响应
64
+ */
65
+ export async function craftSendSol(inviteSigner, sender, amountLamports, config) {
66
+ return craftSend({
67
+ inviteSigner,
68
+ sender,
69
+ amount: amountLamports.toString(),
70
+ // 不传 mint 默认为 WSOL
71
+ }, config);
72
+ }
73
+ /**
74
+ * 创建 USDC 发送邀请
75
+ *
76
+ * @param inviteSigner 邀请签名者公钥
77
+ * @param sender 发送者地址
78
+ * @param amountUsdc USDC 数量(原子单位,6位小数)
79
+ * @param config Jupiter 配置
80
+ * @returns 创建响应
81
+ */
82
+ export async function craftSendUsdc(inviteSigner, sender, amountUsdc, config) {
83
+ return craftSend({
84
+ inviteSigner,
85
+ sender,
86
+ amount: amountUsdc.toString(),
87
+ mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
88
+ }, config);
89
+ }
90
+ // ============================================================================
91
+ // Craft Clawback - 撤回邀请
92
+ // ============================================================================
93
+ /**
94
+ * 撤回/取消邀请
95
+ *
96
+ * 撤回未领取的邀请,资金返还给发送者。
97
+ *
98
+ * @param params 撤回参数
99
+ * @param config Jupiter 配置
100
+ * @returns 撤回响应
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // 撤回邀请
105
+ * const result = await Sol.craftClawback({
106
+ * invitePDA: 'invitePDAAddress...',
107
+ * sender: wallet.publicKey.toBase58(),
108
+ * })
109
+ *
110
+ * // 签名并发送交易
111
+ * const tx = VersionedTransaction.deserialize(Buffer.from(result.tx, 'base64'))
112
+ * tx.sign([wallet])
113
+ * // 发送交易...
114
+ * ```
115
+ */
116
+ export async function craftClawback(params, config) {
117
+ return jupPost('/send/v1/craft-clawback', params, config);
118
+ }
119
+ // ============================================================================
120
+ // Pending Invites - 待处理邀请
121
+ // ============================================================================
122
+ /**
123
+ * 获取待处理的邀请
124
+ *
125
+ * 获取发送者创建的尚未被领取或撤回的邀请。
126
+ *
127
+ * @param address 发送者地址
128
+ * @param page 页码(默认 1)
129
+ * @param config Jupiter 配置
130
+ * @returns 邀请列表响应
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const pending = await Sol.getPendingInvites(
135
+ * wallet.publicKey.toBase58(),
136
+ * 1,
137
+ * )
138
+ *
139
+ * console.log(`待处理邀请: ${pending.invites.length}`)
140
+ * pending.invites.forEach(invite => {
141
+ * console.log(`金额: ${invite.amount}`)
142
+ * console.log(`过期: ${new Date(parseInt(invite.expiry) * 1000)}`)
143
+ * })
144
+ * ```
145
+ */
146
+ export async function getPendingInvites(address, page = 1, config) {
147
+ return jupGet('/send/v1/pending-invites', { address, page }, config);
148
+ }
149
+ /**
150
+ * 获取所有待处理邀请(自动分页)
151
+ *
152
+ * @param address 发送者地址
153
+ * @param config Jupiter 配置
154
+ * @returns 所有待处理邀请
155
+ */
156
+ export async function getAllPendingInvites(address, config) {
157
+ const allInvites = [];
158
+ let page = 1;
159
+ while (true) {
160
+ const response = await getPendingInvites(address, page, config);
161
+ allInvites.push(...response.invites);
162
+ if (!response.hasMoreData)
163
+ break;
164
+ page++;
165
+ }
166
+ return allInvites;
167
+ }
168
+ // ============================================================================
169
+ // Invite History - 邀请历史
170
+ // ============================================================================
171
+ /**
172
+ * 获取邀请历史
173
+ *
174
+ * 获取地址相关的所有邀请历史(作为发送者或接收者)。
175
+ *
176
+ * @param address 地址(发送者或接收者)
177
+ * @param page 页码(默认 1)
178
+ * @param config Jupiter 配置
179
+ * @returns 邀请列表响应
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const history = await Sol.getInviteHistory(
184
+ * wallet.publicKey.toBase58(),
185
+ * 1,
186
+ * )
187
+ *
188
+ * console.log(`邀请历史: ${history.invites.length}`)
189
+ * history.invites.forEach(invite => {
190
+ * console.log(`${invite.action}: ${invite.amount}`)
191
+ * console.log(` 发送者: ${invite.sender}`)
192
+ * console.log(` 接收者: ${invite.receiver}`)
193
+ * })
194
+ * ```
195
+ */
196
+ export async function getInviteHistory(address, page = 1, config) {
197
+ return jupGet('/send/v1/invite-history', { address, page }, config);
198
+ }
199
+ /**
200
+ * 获取所有邀请历史(自动分页)
201
+ *
202
+ * @param address 地址
203
+ * @param config Jupiter 配置
204
+ * @returns 所有邀请历史
205
+ */
206
+ export async function getAllInviteHistory(address, config) {
207
+ const allInvites = [];
208
+ let page = 1;
209
+ while (true) {
210
+ const response = await getInviteHistory(address, page, config);
211
+ allInvites.push(...response.invites);
212
+ if (!response.hasMoreData)
213
+ break;
214
+ page++;
215
+ }
216
+ return allInvites;
217
+ }
218
+ // ============================================================================
219
+ // 便捷方法
220
+ // ============================================================================
221
+ /**
222
+ * 获取待处理邀请总金额
223
+ *
224
+ * @param address 发送者地址
225
+ * @param config Jupiter 配置
226
+ * @returns 总金额(按 mint 分组)
227
+ */
228
+ export async function getPendingInvitesTotal(address, config) {
229
+ const invites = await getAllPendingInvites(address, config);
230
+ const totals = new Map();
231
+ invites.forEach(invite => {
232
+ const mint = invite.mint || 'So11111111111111111111111111111111111111112';
233
+ const current = totals.get(mint) || BigInt(0);
234
+ totals.set(mint, current + BigInt(invite.amount));
235
+ });
236
+ return totals;
237
+ }
238
+ /**
239
+ * 获取即将过期的邀请
240
+ *
241
+ * @param address 发送者地址
242
+ * @param withinHours 在多少小时内过期(默认 24)
243
+ * @param config Jupiter 配置
244
+ * @returns 即将过期的邀请
245
+ */
246
+ export async function getExpiringInvites(address, withinHours = 24, config) {
247
+ const invites = await getAllPendingInvites(address, config);
248
+ const now = Math.floor(Date.now() / 1000);
249
+ const cutoff = now + (withinHours * 3600);
250
+ return invites.filter(invite => {
251
+ const expiry = parseInt(invite.expiry);
252
+ return expiry <= cutoff && expiry > now;
253
+ });
254
+ }
255
+ /**
256
+ * 检查邀请是否已过期
257
+ *
258
+ * @param invite 邀请信息
259
+ * @returns 是否已过期
260
+ */
261
+ export function isInviteExpired(invite) {
262
+ const now = Math.floor(Date.now() / 1000);
263
+ return parseInt(invite.expiry) <= now;
264
+ }
265
+ /**
266
+ * 获取邀请剩余时间(秒)
267
+ *
268
+ * @param invite 邀请信息
269
+ * @returns 剩余秒数(已过期返回 0)
270
+ */
271
+ export function getInviteTimeRemaining(invite) {
272
+ const now = Math.floor(Date.now() / 1000);
273
+ const expiry = parseInt(invite.expiry);
274
+ return Math.max(0, expiry - now);
275
+ }
276
+ /**
277
+ * 筛选发送的邀请
278
+ *
279
+ * @param invites 邀请列表
280
+ * @param sender 发送者地址
281
+ * @returns 发送的邀请
282
+ */
283
+ export function filterSentInvites(invites, sender) {
284
+ return invites.filter(i => i.sender === sender);
285
+ }
286
+ /**
287
+ * 筛选接收的邀请
288
+ *
289
+ * @param invites 邀请列表
290
+ * @param receiver 接收者地址
291
+ * @returns 接收的邀请
292
+ */
293
+ export function filterReceivedInvites(invites, receiver) {
294
+ return invites.filter(i => i.receiver === receiver);
295
+ }