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.
- 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 +75 -0
- package/dist/sol/utils/lp-inspect.js +235 -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 +44 -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,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meteora 通用类型定义
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* DBC 迁移费用选项
|
|
6
|
+
*/
|
|
7
|
+
export var DbcMigrationFeeOption;
|
|
8
|
+
(function (DbcMigrationFeeOption) {
|
|
9
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps25"] = 0] = "FixedBps25";
|
|
10
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps30"] = 1] = "FixedBps30";
|
|
11
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps100"] = 2] = "FixedBps100";
|
|
12
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps200"] = 3] = "FixedBps200";
|
|
13
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps400"] = 4] = "FixedBps400";
|
|
14
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["FixedBps600"] = 5] = "FixedBps600";
|
|
15
|
+
DbcMigrationFeeOption[DbcMigrationFeeOption["Customizable"] = 6] = "Customizable";
|
|
16
|
+
})(DbcMigrationFeeOption || (DbcMigrationFeeOption = {}));
|
|
17
|
+
/**
|
|
18
|
+
* DBC 激活类型
|
|
19
|
+
*/
|
|
20
|
+
export var DbcActivationType;
|
|
21
|
+
(function (DbcActivationType) {
|
|
22
|
+
DbcActivationType[DbcActivationType["Slot"] = 0] = "Slot";
|
|
23
|
+
DbcActivationType[DbcActivationType["Timestamp"] = 1] = "Timestamp";
|
|
24
|
+
})(DbcActivationType || (DbcActivationType = {}));
|
|
25
|
+
/**
|
|
26
|
+
* DBC 代币类型
|
|
27
|
+
*/
|
|
28
|
+
export var DbcTokenType;
|
|
29
|
+
(function (DbcTokenType) {
|
|
30
|
+
DbcTokenType[DbcTokenType["Token"] = 0] = "Token";
|
|
31
|
+
DbcTokenType[DbcTokenType["Token2022"] = 1] = "Token2022";
|
|
32
|
+
})(DbcTokenType || (DbcTokenType = {}));
|
|
33
|
+
/**
|
|
34
|
+
* DBC 迁移目标
|
|
35
|
+
*/
|
|
36
|
+
export var DbcMigrationOption;
|
|
37
|
+
(function (DbcMigrationOption) {
|
|
38
|
+
DbcMigrationOption[DbcMigrationOption["DammV1"] = 0] = "DammV1";
|
|
39
|
+
DbcMigrationOption[DbcMigrationOption["DammV2"] = 1] = "DammV2";
|
|
40
|
+
})(DbcMigrationOption || (DbcMigrationOption = {}));
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// DBC 扩展类型
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* DBC 费用模式
|
|
46
|
+
*/
|
|
47
|
+
export var DbcBaseFeeMode;
|
|
48
|
+
(function (DbcBaseFeeMode) {
|
|
49
|
+
DbcBaseFeeMode[DbcBaseFeeMode["FeeSchedulerLinear"] = 0] = "FeeSchedulerLinear";
|
|
50
|
+
DbcBaseFeeMode[DbcBaseFeeMode["FeeSchedulerExponential"] = 1] = "FeeSchedulerExponential";
|
|
51
|
+
DbcBaseFeeMode[DbcBaseFeeMode["RateLimiter"] = 2] = "RateLimiter";
|
|
52
|
+
})(DbcBaseFeeMode || (DbcBaseFeeMode = {}));
|
|
53
|
+
/**
|
|
54
|
+
* DBC 费用收取模式
|
|
55
|
+
*/
|
|
56
|
+
export var DbcCollectFeeMode;
|
|
57
|
+
(function (DbcCollectFeeMode) {
|
|
58
|
+
DbcCollectFeeMode[DbcCollectFeeMode["QuoteToken"] = 0] = "QuoteToken";
|
|
59
|
+
DbcCollectFeeMode[DbcCollectFeeMode["OutputToken"] = 1] = "OutputToken";
|
|
60
|
+
})(DbcCollectFeeMode || (DbcCollectFeeMode = {}));
|
|
61
|
+
/**
|
|
62
|
+
* DBC 代币更新权限
|
|
63
|
+
*/
|
|
64
|
+
export var DbcTokenUpdateAuthority;
|
|
65
|
+
(function (DbcTokenUpdateAuthority) {
|
|
66
|
+
DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["CreatorUpdateAuthority"] = 0] = "CreatorUpdateAuthority";
|
|
67
|
+
DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["Immutable"] = 1] = "Immutable";
|
|
68
|
+
DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["PartnerUpdateAuthority"] = 2] = "PartnerUpdateAuthority";
|
|
69
|
+
DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["CreatorUpdateAndMintAuthority"] = 3] = "CreatorUpdateAndMintAuthority";
|
|
70
|
+
DbcTokenUpdateAuthority[DbcTokenUpdateAuthority["PartnerUpdateAndMintAuthority"] = 4] = "PartnerUpdateAndMintAuthority";
|
|
71
|
+
})(DbcTokenUpdateAuthority || (DbcTokenUpdateAuthority = {}));
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// 常量
|
|
74
|
+
// ============================================================================
|
|
75
|
+
/**
|
|
76
|
+
* Meteora Program IDs
|
|
77
|
+
*/
|
|
78
|
+
export const METEORA_PROGRAM_IDS = {
|
|
79
|
+
/** DLMM Program */
|
|
80
|
+
DLMM: 'LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo',
|
|
81
|
+
/** Dynamic Bonding Curve Program */
|
|
82
|
+
DBC: 'dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN',
|
|
83
|
+
/** DAMM v1 Program */
|
|
84
|
+
DAMM_V1: 'Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB',
|
|
85
|
+
/** DAMM v2 (CP-AMM) Program */
|
|
86
|
+
DAMM_V2: 'cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG',
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* DBC DAMM V1 迁移费用配置地址
|
|
90
|
+
*/
|
|
91
|
+
export const DBC_DAMM_V1_MIGRATION_FEE_ADDRESS = {
|
|
92
|
+
[DbcMigrationFeeOption.FixedBps25]: '8f848CEy8eY6PhJ3VcemtBDzPPSD4Vq7aJczLZ3o8MmX',
|
|
93
|
+
[DbcMigrationFeeOption.FixedBps30]: 'HBxB8Lf14Yj8pqeJ8C4qDb5ryHL7xwpuykz31BLNYr7S',
|
|
94
|
+
[DbcMigrationFeeOption.FixedBps100]: '7v5vBdUQHTNeqk1HnduiXcgbvCyVEZ612HLmYkQoAkik',
|
|
95
|
+
[DbcMigrationFeeOption.FixedBps200]: 'EkvP7d5yKxovj884d2DwmBQbrHUWRLGK6bympzrkXGja',
|
|
96
|
+
[DbcMigrationFeeOption.FixedBps400]: '9EZYAJrcqNWNQzP2trzZesP7XKMHA1jEomHzbRsdX8R2',
|
|
97
|
+
[DbcMigrationFeeOption.FixedBps600]: '8cdKo87jZU2R12KY1BUjjRPwyjgdNjLGqSGQyrDshhud',
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* DBC DAMM V2 迁移费用配置地址
|
|
101
|
+
*/
|
|
102
|
+
export const DBC_DAMM_V2_MIGRATION_FEE_ADDRESS = {
|
|
103
|
+
[DbcMigrationFeeOption.FixedBps25]: '7F6dnUcRuyM2TwR8myT1dYypFXpPSxqwKNSFNkxyNESd',
|
|
104
|
+
[DbcMigrationFeeOption.FixedBps30]: '2nHK1kju6XjphBLbNxpM5XRGFj7p9U8vvNzyZiha1z6k',
|
|
105
|
+
[DbcMigrationFeeOption.FixedBps100]: 'Hv8Lmzmnju6m7kcokVKvwqz7QPmdX9XfKjJsXz8RXcjp',
|
|
106
|
+
[DbcMigrationFeeOption.FixedBps200]: '2c4cYd4reUYVRAB9kUUkrq55VPyy2FNQ3FDL4o12JXmq',
|
|
107
|
+
[DbcMigrationFeeOption.FixedBps400]: 'AkmQWebAwFvWk55wBoCr5D62C6VVDTzi84NJuD9H7cFD',
|
|
108
|
+
[DbcMigrationFeeOption.FixedBps600]: 'DbCRBj8McvPYHJG1ukj8RE15h2dCNUdTAESG49XpQ44u',
|
|
109
|
+
[DbcMigrationFeeOption.Customizable]: 'A8gMrEPJkacWkcb3DGwtJwTe16HktSEfvwtuDh2MCtck',
|
|
110
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orca 模块导出
|
|
3
|
+
* 包含 Whirlpool (流动性池) 和 Wavebreak (代币发射平台)
|
|
4
|
+
*/
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export { createOrcaContext, createOrcaClient, getOrcaPoolInfo, findOrcaPool, signOrcaSwap, signOrcaAddLiquidity, signOrcaRemoveLiquidity, signOrcaCreatePool, signOrcaCollectFees, getOrcaPositionInfo, getFullRangeTickIndices, getTickIndicesFromPriceRange, } from './orca.js';
|
|
7
|
+
export { signOrcaBundleBuy, signOrcaBundleSell, signOrcaBundleSwap, toOrcaBundleApiRequest, batchGetOrcaPoolInfo, } from './orca-bundle.js';
|
|
8
|
+
export * from './wavebreak-types.js';
|
|
9
|
+
export { getWavebreakBondingCurveAddress, getWavebreakBondingCurveAddressSync, getWavebreakQuoteVaultAddressSync, getWavebreakLpEscrowAddressSync, getWavebreakBondingCurveInfo, getWavebreakBuyQuote, getWavebreakSellQuote, signWavebreakBuy, signWavebreakSell, signWavebreakCreateLaunch, buildWavebreakBuyInstruction, buildWavebreakSellInstruction, buildWavebreakCreateLaunchInstruction, toWavebreakApiRequest, } from './wavebreak.js';
|
|
10
|
+
export { signWavebreakBundleBuy, signWavebreakBundleSell, signWavebreakBundleCreateAndBuy, toWavebreakBundleApiRequest, } from './wavebreak-bundle.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orca 模块导出
|
|
3
|
+
* 包含 Whirlpool (流动性池) 和 Wavebreak (代币发射平台)
|
|
4
|
+
*/
|
|
5
|
+
// ===== Whirlpool 类型 =====
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
// ===== Whirlpool 核心功能 =====
|
|
8
|
+
export { createOrcaContext, createOrcaClient, getOrcaPoolInfo, findOrcaPool, signOrcaSwap, signOrcaAddLiquidity, signOrcaRemoveLiquidity, signOrcaCreatePool, signOrcaCollectFees, getOrcaPositionInfo, getFullRangeTickIndices, getTickIndicesFromPriceRange, } from './orca.js';
|
|
9
|
+
// ===== Whirlpool Bundle 批量交易 =====
|
|
10
|
+
export { signOrcaBundleBuy, signOrcaBundleSell, signOrcaBundleSwap, toOrcaBundleApiRequest, batchGetOrcaPoolInfo, } from './orca-bundle.js';
|
|
11
|
+
// ===== Wavebreak 类型 =====
|
|
12
|
+
export * from './wavebreak-types.js';
|
|
13
|
+
// ===== Wavebreak 核心功能 =====
|
|
14
|
+
export { getWavebreakBondingCurveAddress, getWavebreakBondingCurveAddressSync, getWavebreakQuoteVaultAddressSync, getWavebreakLpEscrowAddressSync, getWavebreakBondingCurveInfo, getWavebreakBuyQuote, getWavebreakSellQuote, signWavebreakBuy, signWavebreakSell, signWavebreakCreateLaunch, buildWavebreakBuyInstruction, buildWavebreakSellInstruction, buildWavebreakCreateLaunchInstruction, toWavebreakApiRequest, } from './wavebreak.js';
|
|
15
|
+
// ===== Wavebreak Bundle 批量交易 =====
|
|
16
|
+
export { signWavebreakBundleBuy, signWavebreakBundleSell, signWavebreakBundleCreateAndBuy, toWavebreakBundleApiRequest, } from './wavebreak-bundle.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orca Whirlpool Jito Bundle 批量交易
|
|
3
|
+
* 支持批量买卖的原子性交易
|
|
4
|
+
*/
|
|
5
|
+
import { Connection } from '@solana/web3.js';
|
|
6
|
+
import type { OrcaBundleSwapParams, OrcaBundleSignedResult } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* 签名 Orca Bundle 批量买入交易
|
|
9
|
+
* 多个钱包同时买入同一个代币
|
|
10
|
+
*/
|
|
11
|
+
export declare function signOrcaBundleBuy(params: OrcaBundleSwapParams, connection?: Connection): Promise<OrcaBundleSignedResult>;
|
|
12
|
+
/**
|
|
13
|
+
* 签名 Orca Bundle 批量卖出交易
|
|
14
|
+
* 多个钱包同时卖出同一个代币
|
|
15
|
+
*/
|
|
16
|
+
export declare function signOrcaBundleSell(params: OrcaBundleSwapParams, connection?: Connection): Promise<OrcaBundleSignedResult>;
|
|
17
|
+
/**
|
|
18
|
+
* 签名 Orca Bundle 批量 Swap 交易 (通用)
|
|
19
|
+
* 支持买入和卖出
|
|
20
|
+
*/
|
|
21
|
+
export declare function signOrcaBundleSwap(params: OrcaBundleSwapParams, connection?: Connection): Promise<OrcaBundleSignedResult>;
|
|
22
|
+
/**
|
|
23
|
+
* 将 Orca Bundle 结果转换为后端 API 请求格式
|
|
24
|
+
*/
|
|
25
|
+
export declare function toOrcaBundleApiRequest(result: OrcaBundleSignedResult): {
|
|
26
|
+
transactions: string[];
|
|
27
|
+
metadata: {
|
|
28
|
+
type: string;
|
|
29
|
+
poolAddress: string;
|
|
30
|
+
tradeCount: number;
|
|
31
|
+
jitoTipLamports: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 批量获取多个池的信息
|
|
36
|
+
*/
|
|
37
|
+
export declare function batchGetOrcaPoolInfo(poolAddresses: string[], connection?: Connection): Promise<Map<string, {
|
|
38
|
+
tokenMintA: string;
|
|
39
|
+
tokenMintB: string;
|
|
40
|
+
tickSpacing: number;
|
|
41
|
+
}>>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orca Whirlpool Jito Bundle 批量交易
|
|
3
|
+
* 支持批量买卖的原子性交易
|
|
4
|
+
*/
|
|
5
|
+
import { PublicKey, Keypair, Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
|
|
6
|
+
import { WhirlpoolContext, buildWhirlpoolClient, ORCA_WHIRLPOOL_PROGRAM_ID, swapQuoteByInputToken, TokenExtensionUtil, } from '@orca-so/whirlpools-sdk';
|
|
7
|
+
import { Percentage } from '@orca-so/common-sdk';
|
|
8
|
+
/**
|
|
9
|
+
* 从 Keypair 创建 Wallet 适配器(兼容浏览器环境)
|
|
10
|
+
*/
|
|
11
|
+
function createWalletFromKeypair(keypair) {
|
|
12
|
+
return {
|
|
13
|
+
publicKey: keypair.publicKey,
|
|
14
|
+
signTransaction: async (tx) => {
|
|
15
|
+
if (tx instanceof Transaction) {
|
|
16
|
+
tx.partialSign(keypair);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
tx.sign([keypair]);
|
|
20
|
+
}
|
|
21
|
+
return tx;
|
|
22
|
+
},
|
|
23
|
+
signAllTransactions: async (txs) => {
|
|
24
|
+
for (const tx of txs) {
|
|
25
|
+
if (tx instanceof Transaction) {
|
|
26
|
+
tx.partialSign(keypair);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
tx.sign([keypair]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return txs;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// 不再导入 createConnection,强制使用者传入连接
|
|
37
|
+
import { buildTipInstruction, getRandomTipAccount } from '../../jito/tip.js';
|
|
38
|
+
/**
|
|
39
|
+
* 默认 Jito 小费 (0.001 SOL)
|
|
40
|
+
*/
|
|
41
|
+
const DEFAULT_JITO_TIP_LAMPORTS = 1000000;
|
|
42
|
+
/**
|
|
43
|
+
* 签名 Orca Bundle 批量买入交易
|
|
44
|
+
* 多个钱包同时买入同一个代币
|
|
45
|
+
*/
|
|
46
|
+
export async function signOrcaBundleBuy(params, connection) {
|
|
47
|
+
return signOrcaBundleSwap(params, connection);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 签名 Orca Bundle 批量卖出交易
|
|
51
|
+
* 多个钱包同时卖出同一个代币
|
|
52
|
+
*/
|
|
53
|
+
export async function signOrcaBundleSell(params, connection) {
|
|
54
|
+
return signOrcaBundleSwap(params, connection);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 签名 Orca Bundle 批量 Swap 交易 (通用)
|
|
58
|
+
* 支持买入和卖出
|
|
59
|
+
*/
|
|
60
|
+
export async function signOrcaBundleSwap(params, connection) {
|
|
61
|
+
if (!connection) {
|
|
62
|
+
throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
|
|
63
|
+
}
|
|
64
|
+
const conn = connection;
|
|
65
|
+
const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
|
|
66
|
+
const signedTransactions = [];
|
|
67
|
+
const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
|
|
68
|
+
// 预加载池信息 (只加载一次)
|
|
69
|
+
const firstWallet = params.trades[0].wallet;
|
|
70
|
+
const ctx = WhirlpoolContext.from(conn, createWalletFromKeypair(firstWallet));
|
|
71
|
+
const client = buildWhirlpoolClient(ctx);
|
|
72
|
+
const pool = await client.getPool(params.poolAddress);
|
|
73
|
+
const tokenInfoA = pool.getTokenAInfo();
|
|
74
|
+
const tokenInfoB = pool.getTokenBInfo();
|
|
75
|
+
// 获取 token extension context
|
|
76
|
+
const tokenExtensionCtx = await TokenExtensionUtil.buildTokenExtensionContextForPool(ctx.fetcher, tokenInfoA.mint, tokenInfoB.mint);
|
|
77
|
+
// 为每个交易创建签名
|
|
78
|
+
for (let i = 0; i < params.trades.length; i++) {
|
|
79
|
+
const trade = params.trades[i];
|
|
80
|
+
const isLastTrade = i === params.trades.length - 1;
|
|
81
|
+
// 创建该钱包的 context
|
|
82
|
+
const walletCtx = WhirlpoolContext.from(conn, createWalletFromKeypair(trade.wallet));
|
|
83
|
+
const walletClient = buildWhirlpoolClient(walletCtx);
|
|
84
|
+
const walletPool = await walletClient.getPool(params.poolAddress);
|
|
85
|
+
// 获取报价
|
|
86
|
+
const slippage = Percentage.fromFraction(100, 10000); // 1% 滑点
|
|
87
|
+
const quote = await swapQuoteByInputToken(walletPool, new PublicKey(params.inputMint), trade.amountIn, slippage, ORCA_WHIRLPOOL_PROGRAM_ID, walletCtx.fetcher);
|
|
88
|
+
// 构建交易
|
|
89
|
+
const tx = new Transaction();
|
|
90
|
+
// 添加计算预算指令
|
|
91
|
+
tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 400000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
|
|
92
|
+
// 获取 swap 交易
|
|
93
|
+
const swapTxBuilder = await walletPool.swap(quote, trade.wallet.publicKey);
|
|
94
|
+
const swapTx = await swapTxBuilder.build();
|
|
95
|
+
// 提取指令
|
|
96
|
+
if ('instructions' in swapTx.transaction) {
|
|
97
|
+
const swapTransaction = swapTx.transaction;
|
|
98
|
+
tx.add(...swapTransaction.instructions);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new Error('VersionedTransaction not supported in bundle mode');
|
|
102
|
+
}
|
|
103
|
+
// 最后一笔交易添加 Jito 小费
|
|
104
|
+
if (isLastTrade) {
|
|
105
|
+
const tipAccount = getRandomTipAccount();
|
|
106
|
+
const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
|
|
107
|
+
tx.add(tipIx);
|
|
108
|
+
}
|
|
109
|
+
// 设置交易参数
|
|
110
|
+
tx.recentBlockhash = blockhash;
|
|
111
|
+
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
112
|
+
tx.feePayer = trade.wallet.publicKey;
|
|
113
|
+
// 签名
|
|
114
|
+
tx.sign(trade.wallet, ...swapTx.signers);
|
|
115
|
+
signedTransactions.push(tx);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
signedTransactions,
|
|
119
|
+
type: 'bundleSwap',
|
|
120
|
+
poolAddress: params.poolAddress,
|
|
121
|
+
tradeCount: params.trades.length,
|
|
122
|
+
jitoTipLamports,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 将 Orca Bundle 结果转换为后端 API 请求格式
|
|
127
|
+
*/
|
|
128
|
+
export function toOrcaBundleApiRequest(result) {
|
|
129
|
+
const transactions = result.signedTransactions.map(tx => {
|
|
130
|
+
if (tx instanceof Transaction) {
|
|
131
|
+
return Buffer.from(tx.serialize()).toString('base64');
|
|
132
|
+
}
|
|
133
|
+
// VersionedTransaction
|
|
134
|
+
return Buffer.from(tx.serialize()).toString('base64');
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
transactions,
|
|
138
|
+
metadata: {
|
|
139
|
+
type: result.type,
|
|
140
|
+
poolAddress: result.poolAddress,
|
|
141
|
+
tradeCount: result.tradeCount,
|
|
142
|
+
jitoTipLamports: result.jitoTipLamports,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 批量获取多个池的信息
|
|
148
|
+
*/
|
|
149
|
+
export async function batchGetOrcaPoolInfo(poolAddresses, connection) {
|
|
150
|
+
if (!connection) {
|
|
151
|
+
throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
|
|
152
|
+
}
|
|
153
|
+
const conn = connection;
|
|
154
|
+
const result = new Map();
|
|
155
|
+
// 创建一个临时钱包用于查询
|
|
156
|
+
const tempWallet = Keypair.generate();
|
|
157
|
+
const ctx = WhirlpoolContext.from(conn, createWalletFromKeypair(tempWallet));
|
|
158
|
+
const client = buildWhirlpoolClient(ctx);
|
|
159
|
+
// 批量获取池信息
|
|
160
|
+
const pools = await client.getPools(poolAddresses);
|
|
161
|
+
for (const pool of pools) {
|
|
162
|
+
const address = pool.getAddress().toBase58();
|
|
163
|
+
const tokenInfoA = pool.getTokenAInfo();
|
|
164
|
+
const tokenInfoB = pool.getTokenBInfo();
|
|
165
|
+
const data = pool.getData();
|
|
166
|
+
result.set(address, {
|
|
167
|
+
tokenMintA: tokenInfoA.mint.toBase58(),
|
|
168
|
+
tokenMintB: tokenInfoB.mint.toBase58(),
|
|
169
|
+
tickSpacing: data.tickSpacing,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orca Whirlpool 核心功能
|
|
3
|
+
* 提供 Swap、LP 添加/移除等功能
|
|
4
|
+
*
|
|
5
|
+
* 基于 @orca-so/whirlpools-sdk (Legacy SDK)
|
|
6
|
+
* 文档: https://dev.orca.so/SDKs/Overview
|
|
7
|
+
*/
|
|
8
|
+
import { Connection, Keypair } from '@solana/web3.js';
|
|
9
|
+
import { WhirlpoolContext, type WhirlpoolClient } from '@orca-so/whirlpools-sdk';
|
|
10
|
+
import type { OrcaPoolInfo, OrcaSwapParams, OrcaAddLiquidityParams, OrcaRemoveLiquidityParams, OrcaPositionInfo, OrcaCreatePoolParams, OrcaSignedResult } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* 创建 Orca Whirlpool Context
|
|
13
|
+
*/
|
|
14
|
+
export declare function createOrcaContext(connection?: Connection, wallet?: Keypair): Promise<WhirlpoolContext>;
|
|
15
|
+
/**
|
|
16
|
+
* 创建 Orca Whirlpool Client
|
|
17
|
+
*/
|
|
18
|
+
export declare function createOrcaClient(connection?: Connection, wallet?: Keypair): Promise<WhirlpoolClient>;
|
|
19
|
+
/**
|
|
20
|
+
* 获取 Orca Whirlpool 池信息
|
|
21
|
+
*/
|
|
22
|
+
export declare function getOrcaPoolInfo(poolAddress: string, connection?: Connection): Promise<OrcaPoolInfo>;
|
|
23
|
+
/**
|
|
24
|
+
* 查找 Orca Whirlpool 池
|
|
25
|
+
*/
|
|
26
|
+
export declare function findOrcaPool(tokenMintA: string, tokenMintB: string, tickSpacing?: number, connection?: Connection): Promise<string | null>;
|
|
27
|
+
/**
|
|
28
|
+
* 签名 Orca Swap 交易
|
|
29
|
+
* 使用 Whirlpool 的高级 swap 接口
|
|
30
|
+
*/
|
|
31
|
+
export declare function signOrcaSwap(params: OrcaSwapParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
|
|
32
|
+
/**
|
|
33
|
+
* 签名 Orca 添加流动性交易
|
|
34
|
+
*/
|
|
35
|
+
export declare function signOrcaAddLiquidity(params: OrcaAddLiquidityParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
|
|
36
|
+
/**
|
|
37
|
+
* 签名 Orca 移除流动性交易
|
|
38
|
+
*/
|
|
39
|
+
export declare function signOrcaRemoveLiquidity(params: OrcaRemoveLiquidityParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
|
|
40
|
+
/**
|
|
41
|
+
* 签名创建 Orca Whirlpool 池交易
|
|
42
|
+
*/
|
|
43
|
+
export declare function signOrcaCreatePool(params: OrcaCreatePoolParams, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
|
|
44
|
+
/**
|
|
45
|
+
* 签名收集费用交易
|
|
46
|
+
*/
|
|
47
|
+
export declare function signOrcaCollectFees(positionAddress: string, payer: Keypair, connection?: Connection): Promise<OrcaSignedResult>;
|
|
48
|
+
/**
|
|
49
|
+
* 获取 Position 信息
|
|
50
|
+
*/
|
|
51
|
+
export declare function getOrcaPositionInfo(positionAddress: string, connection?: Connection): Promise<OrcaPositionInfo>;
|
|
52
|
+
/**
|
|
53
|
+
* 计算全范围流动性的 tick 范围
|
|
54
|
+
*/
|
|
55
|
+
export declare function getFullRangeTickIndices(tickSpacing: number): {
|
|
56
|
+
tickLower: number;
|
|
57
|
+
tickUpper: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* 根据价格范围计算 tick 范围
|
|
61
|
+
*/
|
|
62
|
+
export declare function getTickIndicesFromPriceRange(priceLower: number, priceUpper: number, decimalsA: number, decimalsB: number, tickSpacing: number): {
|
|
63
|
+
tickLower: number;
|
|
64
|
+
tickUpper: number;
|
|
65
|
+
};
|