four-flap-meme-sdk 1.5.4 → 1.5.6
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/dist/abis/common.js +0 -2
- package/dist/contracts/tm-bundle-merkle/config.d.ts +1 -0
- package/dist/contracts/tm-bundle-merkle/config.js +1 -0
- package/dist/contracts/tm-bundle-merkle/core.js +9 -13
- package/dist/flap/portal-bundle-merkle/config.d.ts +1 -0
- package/dist/flap/portal-bundle-merkle/config.js +1 -0
- package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +2 -8
- package/dist/flap/portal-bundle-merkle/create-to-dex.js +126 -154
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/sol/constants.d.ts +150 -0
- package/dist/sol/constants.js +188 -0
- package/dist/sol/dex/blockrazor/client.d.ts +51 -0
- package/dist/sol/dex/blockrazor/client.js +96 -0
- package/dist/sol/dex/blockrazor/constants.d.ts +34 -0
- package/dist/sol/dex/blockrazor/constants.js +55 -0
- package/dist/sol/dex/blockrazor/geyser.d.ts +128 -0
- package/dist/sol/dex/blockrazor/geyser.js +530 -0
- package/dist/sol/dex/blockrazor/index.d.ts +18 -0
- package/dist/sol/dex/blockrazor/index.js +23 -0
- package/dist/sol/dex/blockrazor/send.d.ts +135 -0
- package/dist/sol/dex/blockrazor/send.js +254 -0
- package/dist/sol/dex/blockrazor/types.d.ts +191 -0
- package/dist/sol/dex/blockrazor/types.js +5 -0
- package/dist/sol/dex/index.d.ts +10 -0
- package/dist/sol/dex/index.js +16 -0
- package/dist/sol/dex/jup/client.d.ts +33 -0
- package/dist/sol/dex/jup/client.js +110 -0
- package/dist/sol/dex/jup/index.d.ts +16 -0
- package/dist/sol/dex/jup/index.js +148 -0
- package/dist/sol/dex/jup/legacy.d.ts +623 -0
- package/dist/sol/dex/jup/legacy.js +416 -0
- package/dist/sol/dex/jup/lend.d.ts +640 -0
- package/dist/sol/dex/jup/lend.js +603 -0
- package/dist/sol/dex/jup/portfolio.d.ts +362 -0
- package/dist/sol/dex/jup/portfolio.js +367 -0
- package/dist/sol/dex/jup/price.d.ts +173 -0
- package/dist/sol/dex/jup/price.js +220 -0
- package/dist/sol/dex/jup/recurring.d.ts +437 -0
- package/dist/sol/dex/jup/recurring.js +320 -0
- package/dist/sol/dex/jup/send.d.ts +282 -0
- package/dist/sol/dex/jup/send.js +295 -0
- package/dist/sol/dex/jup/studio.d.ts +457 -0
- package/dist/sol/dex/jup/studio.js +488 -0
- package/dist/sol/dex/jup/tokens.d.ts +767 -0
- package/dist/sol/dex/jup/tokens.js +697 -0
- package/dist/sol/dex/jup/trigger.d.ts +511 -0
- package/dist/sol/dex/jup/trigger.js +397 -0
- package/dist/sol/dex/jup/types.d.ts +433 -0
- package/dist/sol/dex/jup/types.js +5 -0
- package/dist/sol/dex/jup/ultra.d.ts +646 -0
- package/dist/sol/dex/jup/ultra.js +853 -0
- package/dist/sol/dex/meteora/client.d.ts +76 -0
- package/dist/sol/dex/meteora/client.js +219 -0
- package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
- package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
- package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
- package/dist/sol/dex/meteora/damm-v1.js +315 -0
- package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
- package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
- package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
- package/dist/sol/dex/meteora/damm-v2.js +632 -0
- package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
- package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
- package/dist/sol/dex/meteora/dbc.d.ts +192 -0
- package/dist/sol/dex/meteora/dbc.js +619 -0
- package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
- package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
- package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
- package/dist/sol/dex/meteora/dlmm.js +671 -0
- package/dist/sol/dex/meteora/index.d.ts +25 -0
- package/dist/sol/dex/meteora/index.js +65 -0
- package/dist/sol/dex/meteora/types.d.ts +787 -0
- package/dist/sol/dex/meteora/types.js +110 -0
- package/dist/sol/dex/orca/index.d.ts +10 -0
- package/dist/sol/dex/orca/index.js +16 -0
- package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
- package/dist/sol/dex/orca/orca-bundle.js +173 -0
- package/dist/sol/dex/orca/orca.d.ts +65 -0
- package/dist/sol/dex/orca/orca.js +474 -0
- package/dist/sol/dex/orca/types.d.ts +263 -0
- package/dist/sol/dex/orca/types.js +38 -0
- package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
- package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
- package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
- package/dist/sol/dex/orca/wavebreak-types.js +23 -0
- package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
- package/dist/sol/dex/orca/wavebreak.js +497 -0
- package/dist/sol/dex/pump/index.d.ts +9 -0
- package/dist/sol/dex/pump/index.js +14 -0
- package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
- package/dist/sol/dex/pump/pump-bundle.js +383 -0
- package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
- package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
- package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
- package/dist/sol/dex/pump/pump-swap.js +199 -0
- package/dist/sol/dex/pump/pump.d.ts +35 -0
- package/dist/sol/dex/pump/pump.js +352 -0
- package/dist/sol/dex/pump/types.d.ts +215 -0
- package/dist/sol/dex/pump/types.js +5 -0
- package/dist/sol/dex/raydium/index.d.ts +8 -0
- package/dist/sol/dex/raydium/index.js +12 -0
- package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
- package/dist/sol/dex/raydium/launchlab.js +210 -0
- package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
- package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
- package/dist/sol/dex/raydium/raydium.d.ts +40 -0
- package/dist/sol/dex/raydium/raydium.js +366 -0
- package/dist/sol/dex/raydium/types.d.ts +240 -0
- package/dist/sol/dex/raydium/types.js +5 -0
- package/dist/sol/index.d.ts +11 -0
- package/dist/sol/index.js +18 -0
- package/dist/sol/jito/bundle.d.ts +90 -0
- package/dist/sol/jito/bundle.js +263 -0
- package/dist/sol/jito/index.d.ts +7 -0
- package/dist/sol/jito/index.js +7 -0
- package/dist/sol/jito/tip.d.ts +51 -0
- package/dist/sol/jito/tip.js +83 -0
- package/dist/sol/jito/types.d.ts +100 -0
- package/dist/sol/jito/types.js +5 -0
- package/dist/sol/nozomi/client.d.ts +63 -0
- package/dist/sol/nozomi/client.js +222 -0
- package/dist/sol/nozomi/index.d.ts +8 -0
- package/dist/sol/nozomi/index.js +8 -0
- package/dist/sol/nozomi/tip.d.ts +50 -0
- package/dist/sol/nozomi/tip.js +80 -0
- package/dist/sol/nozomi/types.d.ts +96 -0
- package/dist/sol/nozomi/types.js +5 -0
- package/dist/sol/token/create-complete.d.ts +115 -0
- package/dist/sol/token/create-complete.js +235 -0
- package/dist/sol/token/create-token.d.ts +57 -0
- package/dist/sol/token/create-token.js +230 -0
- package/dist/sol/token/index.d.ts +9 -0
- package/dist/sol/token/index.js +14 -0
- package/dist/sol/token/metadata-upload.d.ts +86 -0
- package/dist/sol/token/metadata-upload.js +173 -0
- package/dist/sol/token/metadata.d.ts +92 -0
- package/dist/sol/token/metadata.js +274 -0
- package/dist/sol/token/types.d.ts +153 -0
- package/dist/sol/token/types.js +5 -0
- package/dist/sol/types.d.ts +176 -0
- package/dist/sol/types.js +7 -0
- package/dist/sol/utils/balance.d.ts +160 -0
- package/dist/sol/utils/balance.js +638 -0
- package/dist/sol/utils/connection.d.ts +78 -0
- package/dist/sol/utils/connection.js +168 -0
- package/dist/sol/utils/index.d.ts +9 -0
- package/dist/sol/utils/index.js +9 -0
- package/dist/sol/utils/lp-inspect.d.ts +129 -0
- package/dist/sol/utils/lp-inspect.js +900 -0
- package/dist/sol/utils/transfer.d.ts +196 -0
- package/dist/sol/utils/transfer.js +307 -0
- package/dist/sol/utils/wallet.d.ts +107 -0
- package/dist/sol/utils/wallet.js +210 -0
- package/package.json +41 -5
- package/README.zh-CN.pdf +0 -0
- package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
- package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jupiter Studio API V1
|
|
3
|
+
* @module sol/dex/jup/studio
|
|
4
|
+
*
|
|
5
|
+
* Studio API 提供在 Meteora DBC (Dynamic Bonding Curve) 上创建代币的功能
|
|
6
|
+
* 支持配置市值、费用、vesting 等参数
|
|
7
|
+
*/
|
|
8
|
+
import { jupGet, jupPost, getBaseUrl, getJupiterConfig } from './client.js';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// 常量
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/** Quote 代币 Mint 地址 */
|
|
13
|
+
export const QUOTE_MINTS = {
|
|
14
|
+
/** USDC */
|
|
15
|
+
USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
16
|
+
/** SOL (Wrapped) */
|
|
17
|
+
SOL: 'So11111111111111111111111111111111111111112',
|
|
18
|
+
/** JUP */
|
|
19
|
+
JUP: 'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN',
|
|
20
|
+
};
|
|
21
|
+
/** Vesting 持续时间常量 */
|
|
22
|
+
export const VESTING_DURATIONS = {
|
|
23
|
+
/** 无 vesting */
|
|
24
|
+
NONE: 0,
|
|
25
|
+
/** 6 个月 (180天) */
|
|
26
|
+
SIX_MONTHS: 15552000,
|
|
27
|
+
/** 约 6 个月 (183天) */
|
|
28
|
+
SIX_MONTHS_183: 15811200,
|
|
29
|
+
/** 1 年 (365天) */
|
|
30
|
+
ONE_YEAR: 31536000,
|
|
31
|
+
};
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Create DBC Pool - 创建 DBC 池
|
|
34
|
+
// ============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* 创建 DBC 池交易
|
|
37
|
+
*
|
|
38
|
+
* 在 Meteora DBC 上创建代币,支持配置市值、费用、vesting 等参数。
|
|
39
|
+
*
|
|
40
|
+
* @param params 创建参数
|
|
41
|
+
* @param config Jupiter 配置
|
|
42
|
+
* @returns 创建响应
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { Sol } from 'four-flap-meme-sdk'
|
|
47
|
+
*
|
|
48
|
+
* Sol.setJupiterConfig({ apiKey: 'your-api-key' })
|
|
49
|
+
*
|
|
50
|
+
* // 创建 DBC 池
|
|
51
|
+
* const result = await Sol.createDbcPoolTx({
|
|
52
|
+
* buildCurveByMarketCapParam: {
|
|
53
|
+
* quoteMint: Sol.QUOTE_MINTS.USDC,
|
|
54
|
+
* initialMarketCap: 16000, // 16k USDC 初始市值
|
|
55
|
+
* migrationMarketCap: 69000, // 69k USDC 迁移市值
|
|
56
|
+
* tokenQuoteDecimal: 6,
|
|
57
|
+
* lockedVestingParam: {
|
|
58
|
+
* totalLockedVestingAmount: 0,
|
|
59
|
+
* cliffUnlockAmount: 0,
|
|
60
|
+
* numberOfVestingPeriod: 0,
|
|
61
|
+
* totalVestingDuration: 0,
|
|
62
|
+
* cliffDurationFromMigrationTime: 0,
|
|
63
|
+
* },
|
|
64
|
+
* },
|
|
65
|
+
* antiSniping: true,
|
|
66
|
+
* fee: { feeBps: 100 },
|
|
67
|
+
* tokenName: 'My Token',
|
|
68
|
+
* tokenSymbol: 'MTK',
|
|
69
|
+
* tokenImageContentType: 'image/png',
|
|
70
|
+
* creator: wallet.publicKey.toBase58(),
|
|
71
|
+
* isLpLocked: true,
|
|
72
|
+
* })
|
|
73
|
+
*
|
|
74
|
+
* console.log(`代币 Mint: ${result.mint}`)
|
|
75
|
+
* console.log(`图片上传 URL: ${result.imagePresignedUrl}`)
|
|
76
|
+
* console.log(`元数据上传 URL: ${result.metadataPresignedUrl}`)
|
|
77
|
+
*
|
|
78
|
+
* // 1. 上传图片
|
|
79
|
+
* await fetch(result.imagePresignedUrl, {
|
|
80
|
+
* method: 'PUT',
|
|
81
|
+
* headers: { 'Content-Type': 'image/png' },
|
|
82
|
+
* body: imageBuffer,
|
|
83
|
+
* })
|
|
84
|
+
*
|
|
85
|
+
* // 2. 上传元数据
|
|
86
|
+
* const metadata = {
|
|
87
|
+
* name: 'My Token',
|
|
88
|
+
* symbol: 'MTK',
|
|
89
|
+
* description: 'Token description',
|
|
90
|
+
* image: result.imageUrl,
|
|
91
|
+
* }
|
|
92
|
+
* await fetch(result.metadataPresignedUrl, {
|
|
93
|
+
* method: 'PUT',
|
|
94
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
95
|
+
* body: JSON.stringify(metadata),
|
|
96
|
+
* })
|
|
97
|
+
*
|
|
98
|
+
* // 3. 签名并发送交易
|
|
99
|
+
* const tx = VersionedTransaction.deserialize(Buffer.from(result.transaction, 'base64'))
|
|
100
|
+
* tx.sign([wallet])
|
|
101
|
+
* // 发送交易...
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export async function createDbcPoolTx(params, config) {
|
|
105
|
+
return jupPost('/studio/v1/dbc-pool/create-tx', params, config);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 创建简单 DBC 池
|
|
109
|
+
*
|
|
110
|
+
* 使用简化参数创建 DBC 池。
|
|
111
|
+
*
|
|
112
|
+
* @param name 代币名称
|
|
113
|
+
* @param symbol 代币符号
|
|
114
|
+
* @param creator 创建者地址
|
|
115
|
+
* @param options 可选参数
|
|
116
|
+
* @param config Jupiter 配置
|
|
117
|
+
* @returns 创建响应
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* // 使用 USDC 作为 quote,默认参数创建
|
|
122
|
+
* const result = await Sol.createSimpleDbcPool(
|
|
123
|
+
* 'My Token',
|
|
124
|
+
* 'MTK',
|
|
125
|
+
* wallet.publicKey.toBase58(),
|
|
126
|
+
* {
|
|
127
|
+
* quoteMint: 'usdc',
|
|
128
|
+
* initialMarketCap: 16000,
|
|
129
|
+
* migrationMarketCap: 69000,
|
|
130
|
+
* },
|
|
131
|
+
* )
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export async function createSimpleDbcPool(name, symbol, creator, options, config) {
|
|
135
|
+
// 解析 quote mint
|
|
136
|
+
let quoteMint;
|
|
137
|
+
const qm = options?.quoteMint?.toLowerCase();
|
|
138
|
+
switch (qm) {
|
|
139
|
+
case 'usdc':
|
|
140
|
+
quoteMint = QUOTE_MINTS.USDC;
|
|
141
|
+
break;
|
|
142
|
+
case 'sol':
|
|
143
|
+
quoteMint = QUOTE_MINTS.SOL;
|
|
144
|
+
break;
|
|
145
|
+
case 'jup':
|
|
146
|
+
quoteMint = QUOTE_MINTS.JUP;
|
|
147
|
+
break;
|
|
148
|
+
default:
|
|
149
|
+
quoteMint = options?.quoteMint || QUOTE_MINTS.USDC;
|
|
150
|
+
}
|
|
151
|
+
// 确定小数位
|
|
152
|
+
const tokenQuoteDecimal = quoteMint === QUOTE_MINTS.SOL ? 9 : 6;
|
|
153
|
+
return createDbcPoolTx({
|
|
154
|
+
buildCurveByMarketCapParam: {
|
|
155
|
+
quoteMint,
|
|
156
|
+
initialMarketCap: options?.initialMarketCap ?? 16000,
|
|
157
|
+
migrationMarketCap: options?.migrationMarketCap ?? 69000,
|
|
158
|
+
tokenQuoteDecimal,
|
|
159
|
+
lockedVestingParam: {
|
|
160
|
+
totalLockedVestingAmount: 0,
|
|
161
|
+
cliffUnlockAmount: 0,
|
|
162
|
+
numberOfVestingPeriod: 0,
|
|
163
|
+
totalVestingDuration: 0,
|
|
164
|
+
cliffDurationFromMigrationTime: 0,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
antiSniping: options?.antiSniping ?? true,
|
|
168
|
+
fee: { feeBps: options?.feeBps ?? 100 },
|
|
169
|
+
tokenName: name,
|
|
170
|
+
tokenSymbol: symbol,
|
|
171
|
+
tokenImageContentType: options?.imageContentType ?? 'image/png',
|
|
172
|
+
creator,
|
|
173
|
+
isLpLocked: options?.isLpLocked ?? true,
|
|
174
|
+
}, config);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* 创建带 Vesting 的 DBC 池
|
|
178
|
+
*
|
|
179
|
+
* @param name 代币名称
|
|
180
|
+
* @param symbol 代币符号
|
|
181
|
+
* @param creator 创建者地址
|
|
182
|
+
* @param vestingPercent Vesting 百分比(0-80)
|
|
183
|
+
* @param vestingDuration Vesting 持续时间
|
|
184
|
+
* @param options 其他选项
|
|
185
|
+
* @param config Jupiter 配置
|
|
186
|
+
* @returns 创建响应
|
|
187
|
+
*/
|
|
188
|
+
export async function createDbcPoolWithVesting(name, symbol, creator, vestingPercent, vestingDuration, options, config) {
|
|
189
|
+
if (vestingPercent < 0 || vestingPercent > 80) {
|
|
190
|
+
throw new Error('vestingPercent 必须在 0-80 之间');
|
|
191
|
+
}
|
|
192
|
+
// 解析 quote mint
|
|
193
|
+
let quoteMint;
|
|
194
|
+
const qm = options?.quoteMint?.toLowerCase();
|
|
195
|
+
switch (qm) {
|
|
196
|
+
case 'usdc':
|
|
197
|
+
quoteMint = QUOTE_MINTS.USDC;
|
|
198
|
+
break;
|
|
199
|
+
case 'sol':
|
|
200
|
+
quoteMint = QUOTE_MINTS.SOL;
|
|
201
|
+
break;
|
|
202
|
+
case 'jup':
|
|
203
|
+
quoteMint = QUOTE_MINTS.JUP;
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
quoteMint = options?.quoteMint || QUOTE_MINTS.USDC;
|
|
207
|
+
}
|
|
208
|
+
const tokenQuoteDecimal = quoteMint === QUOTE_MINTS.SOL ? 9 : 6;
|
|
209
|
+
// 计算 vesting 期数
|
|
210
|
+
let numberOfVestingPeriod = 0;
|
|
211
|
+
if (vestingDuration === VESTING_DURATIONS.SIX_MONTHS) {
|
|
212
|
+
numberOfVestingPeriod = 6;
|
|
213
|
+
}
|
|
214
|
+
else if (vestingDuration === VESTING_DURATIONS.SIX_MONTHS_183) {
|
|
215
|
+
numberOfVestingPeriod = 183;
|
|
216
|
+
}
|
|
217
|
+
else if (vestingDuration === VESTING_DURATIONS.ONE_YEAR) {
|
|
218
|
+
numberOfVestingPeriod = 12;
|
|
219
|
+
}
|
|
220
|
+
return createDbcPoolTx({
|
|
221
|
+
buildCurveByMarketCapParam: {
|
|
222
|
+
quoteMint,
|
|
223
|
+
initialMarketCap: options?.initialMarketCap ?? 16000,
|
|
224
|
+
migrationMarketCap: options?.migrationMarketCap ?? 69000,
|
|
225
|
+
tokenQuoteDecimal,
|
|
226
|
+
lockedVestingParam: {
|
|
227
|
+
totalLockedVestingAmount: vestingPercent,
|
|
228
|
+
cliffUnlockAmount: 0,
|
|
229
|
+
numberOfVestingPeriod,
|
|
230
|
+
totalVestingDuration: vestingDuration,
|
|
231
|
+
cliffDurationFromMigrationTime: options?.cliffDuration ?? 0,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
antiSniping: true,
|
|
235
|
+
fee: { feeBps: 100 },
|
|
236
|
+
tokenName: name,
|
|
237
|
+
tokenSymbol: symbol,
|
|
238
|
+
tokenImageContentType: options?.imageContentType ?? 'image/png',
|
|
239
|
+
creator,
|
|
240
|
+
isLpLocked: true,
|
|
241
|
+
}, config);
|
|
242
|
+
}
|
|
243
|
+
// ============================================================================
|
|
244
|
+
// Submit DBC Pool - 提交 DBC 池
|
|
245
|
+
// ============================================================================
|
|
246
|
+
/**
|
|
247
|
+
* 提交 DBC 池交易
|
|
248
|
+
*
|
|
249
|
+
* 提交已签名的交易到链上创建 DBC 池。
|
|
250
|
+
*
|
|
251
|
+
* @param params 提交参数
|
|
252
|
+
* @param config Jupiter 配置
|
|
253
|
+
* @returns 提交响应
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* // 签名交易后提交
|
|
258
|
+
* const result = await Sol.submitDbcPool({
|
|
259
|
+
* transaction: signedTxBase64,
|
|
260
|
+
* owner: wallet.publicKey.toBase58(),
|
|
261
|
+
* content: 'My awesome token description',
|
|
262
|
+
* })
|
|
263
|
+
*
|
|
264
|
+
* if (result.success) {
|
|
265
|
+
* console.log(`创建成功: ${result.data.mint}`)
|
|
266
|
+
* console.log(`配置 Key: ${result.data.configKey}`)
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export async function submitDbcPool(params, config) {
|
|
271
|
+
const baseUrl = getBaseUrl(config);
|
|
272
|
+
const cfg = getJupiterConfig(config);
|
|
273
|
+
const formData = new FormData();
|
|
274
|
+
formData.append('transaction', params.transaction);
|
|
275
|
+
formData.append('owner', params.owner);
|
|
276
|
+
if (params.content) {
|
|
277
|
+
formData.append('content', params.content);
|
|
278
|
+
}
|
|
279
|
+
if (params.headerImage) {
|
|
280
|
+
formData.append('headerImage', params.headerImage);
|
|
281
|
+
}
|
|
282
|
+
const response = await fetch(`${baseUrl}/studio/v1/dbc-pool/submit`, {
|
|
283
|
+
method: 'POST',
|
|
284
|
+
headers: {
|
|
285
|
+
'x-api-key': cfg.apiKey,
|
|
286
|
+
// Note: Don't set Content-Type for FormData, browser will set it with boundary
|
|
287
|
+
},
|
|
288
|
+
body: formData,
|
|
289
|
+
});
|
|
290
|
+
if (!response.ok) {
|
|
291
|
+
const errorText = await response.text();
|
|
292
|
+
throw new Error(`Jupiter API error (${response.status}): ${errorText}`);
|
|
293
|
+
}
|
|
294
|
+
return await response.json();
|
|
295
|
+
}
|
|
296
|
+
// ============================================================================
|
|
297
|
+
// Pool Addresses - 获取池地址
|
|
298
|
+
// ============================================================================
|
|
299
|
+
/**
|
|
300
|
+
* 获取 DBC 池地址
|
|
301
|
+
*
|
|
302
|
+
* @param mint 代币 Mint 地址
|
|
303
|
+
* @param config Jupiter 配置
|
|
304
|
+
* @returns 池地址响应
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* const addresses = await Sol.getDbcPoolAddresses('tokenMintAddress...')
|
|
309
|
+
*
|
|
310
|
+
* if (addresses.success) {
|
|
311
|
+
* console.log(`DBC 池: ${addresses.data.dbcPoolAddress}`)
|
|
312
|
+
* console.log(`DAMM V2 池: ${addresses.data.dammv2PoolAddress}`)
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export async function getDbcPoolAddresses(mint, config) {
|
|
317
|
+
return jupGet(`/studio/v1/dbc-pool/addresses/${mint}`, {}, config);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 获取 DBC 池地址(仅地址)
|
|
321
|
+
*
|
|
322
|
+
* @param mint 代币 Mint 地址
|
|
323
|
+
* @param config Jupiter 配置
|
|
324
|
+
* @returns DBC 池地址或 null
|
|
325
|
+
*/
|
|
326
|
+
export async function getDbcPoolAddress(mint, config) {
|
|
327
|
+
const response = await getDbcPoolAddresses(mint, config);
|
|
328
|
+
return response.data?.dbcPoolAddress ?? null;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 获取 DAMM V2 池地址
|
|
332
|
+
*
|
|
333
|
+
* @param mint 代币 Mint 地址
|
|
334
|
+
* @param config Jupiter 配置
|
|
335
|
+
* @returns DAMM V2 池地址或 null
|
|
336
|
+
*/
|
|
337
|
+
export async function getDammV2PoolAddress(mint, config) {
|
|
338
|
+
const response = await getDbcPoolAddresses(mint, config);
|
|
339
|
+
return response.data?.dammv2PoolAddress ?? null;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* 检查代币是否已迁移到 DAMM V2
|
|
343
|
+
*
|
|
344
|
+
* @param mint 代币 Mint 地址
|
|
345
|
+
* @param config Jupiter 配置
|
|
346
|
+
* @returns 是否已迁移
|
|
347
|
+
*/
|
|
348
|
+
export async function isTokenMigrated(mint, config) {
|
|
349
|
+
const response = await getDbcPoolAddresses(mint, config);
|
|
350
|
+
return response.data?.dammv2PoolAddress !== null;
|
|
351
|
+
}
|
|
352
|
+
// ============================================================================
|
|
353
|
+
// DBC Fee - 费用管理
|
|
354
|
+
// ============================================================================
|
|
355
|
+
/**
|
|
356
|
+
* 获取 DBC 费用信息
|
|
357
|
+
*
|
|
358
|
+
* @param poolAddress DBC 池地址
|
|
359
|
+
* @param config Jupiter 配置
|
|
360
|
+
* @returns 费用信息
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* const fee = await Sol.getDbcFee('poolAddress...')
|
|
365
|
+
*
|
|
366
|
+
* console.log(`未领取: ${fee.unclaimed}`)
|
|
367
|
+
* console.log(`总计: ${fee.total}`)
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
export async function getDbcFee(poolAddress, config) {
|
|
371
|
+
return jupPost('/studio/v1/dbc/fee', { poolAddress }, config);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 创建领取 DBC 费用交易
|
|
375
|
+
*
|
|
376
|
+
* @param params 领取参数
|
|
377
|
+
* @param config Jupiter 配置
|
|
378
|
+
* @returns 领取响应
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* // 获取未领取费用
|
|
383
|
+
* const fee = await Sol.getDbcFee('poolAddress...')
|
|
384
|
+
*
|
|
385
|
+
* if (BigInt(fee.unclaimed) > 0) {
|
|
386
|
+
* // 创建领取交易
|
|
387
|
+
* const result = await Sol.createClaimDbcFeeTx({
|
|
388
|
+
* ownerWallet: wallet.publicKey.toBase58(),
|
|
389
|
+
* poolAddress: 'poolAddress...',
|
|
390
|
+
* maxQuoteAmount: Number(fee.unclaimed),
|
|
391
|
+
* })
|
|
392
|
+
*
|
|
393
|
+
* // 签名并发送
|
|
394
|
+
* const tx = VersionedTransaction.deserialize(
|
|
395
|
+
* Buffer.from(result.transaction, 'base64')
|
|
396
|
+
* )
|
|
397
|
+
* tx.sign([wallet])
|
|
398
|
+
* // 发送交易...
|
|
399
|
+
* }
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
export async function createClaimDbcFeeTx(params, config) {
|
|
403
|
+
return jupPost('/studio/v1/dbc/fee/create-tx', params, config);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* 领取所有未领取的 DBC 费用
|
|
407
|
+
*
|
|
408
|
+
* @param ownerWallet 所有者钱包
|
|
409
|
+
* @param poolAddress 池地址
|
|
410
|
+
* @param config Jupiter 配置
|
|
411
|
+
* @returns 领取交易或 null(无费用可领)
|
|
412
|
+
*/
|
|
413
|
+
export async function claimAllDbcFee(ownerWallet, poolAddress, config) {
|
|
414
|
+
const fee = await getDbcFee(poolAddress, config);
|
|
415
|
+
const unclaimed = BigInt(fee.unclaimed);
|
|
416
|
+
if (unclaimed <= 0) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
return createClaimDbcFeeTx({
|
|
420
|
+
ownerWallet,
|
|
421
|
+
poolAddress,
|
|
422
|
+
maxQuoteAmount: Number(unclaimed),
|
|
423
|
+
}, config);
|
|
424
|
+
}
|
|
425
|
+
// ============================================================================
|
|
426
|
+
// 便捷方法
|
|
427
|
+
// ============================================================================
|
|
428
|
+
/**
|
|
429
|
+
* 生成代币元数据
|
|
430
|
+
*
|
|
431
|
+
* @param name 代币名称
|
|
432
|
+
* @param symbol 代币符号
|
|
433
|
+
* @param description 描述
|
|
434
|
+
* @param imageUrl 图片 URL
|
|
435
|
+
* @param options 其他选项
|
|
436
|
+
* @returns 元数据 JSON 字符串
|
|
437
|
+
*/
|
|
438
|
+
export function generateTokenMetadata(name, symbol, description, imageUrl, options) {
|
|
439
|
+
const metadata = {
|
|
440
|
+
name,
|
|
441
|
+
symbol,
|
|
442
|
+
description,
|
|
443
|
+
image: imageUrl,
|
|
444
|
+
};
|
|
445
|
+
if (options?.externalUrl)
|
|
446
|
+
metadata.external_url = options.externalUrl;
|
|
447
|
+
if (options?.twitter)
|
|
448
|
+
metadata.twitter = options.twitter;
|
|
449
|
+
if (options?.telegram)
|
|
450
|
+
metadata.telegram = options.telegram;
|
|
451
|
+
if (options?.discord)
|
|
452
|
+
metadata.discord = options.discord;
|
|
453
|
+
if (options?.website)
|
|
454
|
+
metadata.website = options.website;
|
|
455
|
+
return JSON.stringify(metadata);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* 上传图片到预签名 URL
|
|
459
|
+
*
|
|
460
|
+
* @param presignedUrl 预签名 URL
|
|
461
|
+
* @param imageData 图片数据 (Buffer 或 Blob)
|
|
462
|
+
* @param contentType 图片类型
|
|
463
|
+
* @returns 是否成功
|
|
464
|
+
*/
|
|
465
|
+
export async function uploadDbcTokenImage(presignedUrl, imageData, contentType) {
|
|
466
|
+
const response = await fetch(presignedUrl, {
|
|
467
|
+
method: 'PUT',
|
|
468
|
+
headers: { 'Content-Type': contentType },
|
|
469
|
+
body: imageData,
|
|
470
|
+
});
|
|
471
|
+
return response.ok;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* 上传元数据到预签名 URL
|
|
475
|
+
*
|
|
476
|
+
* @param presignedUrl 预签名 URL
|
|
477
|
+
* @param metadata 元数据对象或 JSON 字符串
|
|
478
|
+
* @returns 是否成功
|
|
479
|
+
*/
|
|
480
|
+
export async function uploadDbcTokenMetadata(presignedUrl, metadata) {
|
|
481
|
+
const body = typeof metadata === 'string' ? metadata : JSON.stringify(metadata);
|
|
482
|
+
const response = await fetch(presignedUrl, {
|
|
483
|
+
method: 'PUT',
|
|
484
|
+
headers: { 'Content-Type': 'application/json' },
|
|
485
|
+
body,
|
|
486
|
+
});
|
|
487
|
+
return response.ok;
|
|
488
|
+
}
|