four-flap-meme-sdk 1.3.81 → 1.3.83
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/contracts/tm-bundle.js +224 -113
- package/dist/flap/portal-bundle-merkle/private.js +87 -107
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sol/constants.d.ts +136 -0
- package/dist/sol/constants.js +156 -0
- package/dist/sol/dex/index.d.ts +8 -0
- package/dist/sol/dex/index.js +12 -0
- package/dist/sol/dex/meteora/client.d.ts +75 -0
- package/dist/sol/dex/meteora/client.js +218 -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 +146 -0
- package/dist/sol/dex/meteora/dlmm.js +593 -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 +140 -0
- package/dist/sol/dex/orca/orca.d.ts +65 -0
- package/dist/sol/dex/orca/orca.js +426 -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 +189 -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 +469 -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 +10 -0
- package/dist/sol/index.js +16 -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/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 +69 -0
- package/dist/sol/utils/connection.js +156 -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 +515 -0
- package/dist/sol/utils/transfer.d.ts +125 -0
- package/dist/sol/utils/transfer.js +220 -0
- package/dist/sol/utils/wallet.d.ts +107 -0
- package/dist/sol/utils/wallet.js +210 -0
- package/dist/utils/airdrop-sweep.js +86 -76
- package/dist/utils/erc20.d.ts +1 -0
- package/dist/utils/erc20.js +22 -20
- package/dist/utils/lp-inspect.js +77 -65
- package/dist/utils/stealth-transfer.js +34 -37
- package/dist/utils/swap-helpers.js +8 -4
- package/package.json +23 -3
- package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
- package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers, Wallet } from 'ethers';
|
|
2
2
|
import { MerkleClient } from '../../clients/merkle.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
|
|
4
4
|
import { FLAP_PORTAL_ADDRESSES } from '../constants.js';
|
|
5
5
|
import { CHAIN_ID_MAP, PORTAL_ABI, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, calculateBatchProfit, getProfitRecipient } from './config.js';
|
|
6
6
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
@@ -13,24 +13,26 @@ export async function flapPrivateBuyMerkle(params) {
|
|
|
13
13
|
const { chainId, provider } = createMerkleContext(chain, config);
|
|
14
14
|
const wallet = new Wallet(privateKey, provider);
|
|
15
15
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
16
|
-
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
17
16
|
const originalAmountWei = ethers.parseEther(amountIn);
|
|
18
17
|
// ✅ 利润提取配置
|
|
19
18
|
const extractProfit = shouldExtractProfit(config);
|
|
20
19
|
const { actualAmountWei, profitWei } = splitBuyAmount(originalAmountWei, extractProfit, config);
|
|
21
20
|
const minAmountOut = parseMinOutput(minOutputAmount);
|
|
22
|
-
const signedTxs = [];
|
|
23
21
|
const portal = new ethers.Contract(portalAddr, PORTAL_ABI, wallet);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
// ✅ 并行获取 gasPrice、nonce 和构建未签名交易
|
|
23
|
+
const [gasPrice, currentNonce, unsigned] = await Promise.all([
|
|
24
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
25
|
+
wallet.getNonce(),
|
|
26
|
+
portal.swapExactInput.populateTransaction({
|
|
27
|
+
inputToken: ZERO_ADDRESS,
|
|
28
|
+
outputToken: tokenAddress,
|
|
29
|
+
inputAmount: actualAmountWei,
|
|
30
|
+
minOutputAmount: minAmountOut,
|
|
31
|
+
permitData: '0x',
|
|
32
|
+
}, { value: actualAmountWei })
|
|
33
|
+
]);
|
|
32
34
|
const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
|
|
33
|
-
const
|
|
35
|
+
const signedTxs = [];
|
|
34
36
|
signedTxs.push(await wallet.signTransaction({
|
|
35
37
|
...unsigned,
|
|
36
38
|
from: wallet.address,
|
|
@@ -39,7 +41,7 @@ export async function flapPrivateBuyMerkle(params) {
|
|
|
39
41
|
gasPrice,
|
|
40
42
|
chainId,
|
|
41
43
|
type: getTxType(config),
|
|
42
|
-
value: actualAmountWei
|
|
44
|
+
value: actualAmountWei
|
|
43
45
|
}));
|
|
44
46
|
await appendSingleProfitTransfer({
|
|
45
47
|
extractProfit,
|
|
@@ -61,11 +63,15 @@ export async function flapPrivateSellMerkle(params) {
|
|
|
61
63
|
const { chainId, provider } = createMerkleContext(chain, config);
|
|
62
64
|
const wallet = new Wallet(privateKey, provider);
|
|
63
65
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
64
|
-
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
65
66
|
const amountWei = ethers.parseUnits(amount, 18);
|
|
66
|
-
// ✅ 自动获取报价以计算预期收益和利润
|
|
67
67
|
const portal = new ethers.Contract(portalAddr, PORTAL_ABI, wallet);
|
|
68
|
-
|
|
68
|
+
// ✅ 并行获取 gasPrice、nonce 和报价
|
|
69
|
+
const [gasPrice, currentNonce, { quotedOutput, minOut }] = await Promise.all([
|
|
70
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
71
|
+
wallet.getNonce(),
|
|
72
|
+
resolveSingleSellOutputs(portal, tokenAddress, amountWei, minOutputAmount)
|
|
73
|
+
]);
|
|
74
|
+
// 构建未签名交易
|
|
69
75
|
const unsigned = await portal.swapExactInput.populateTransaction({
|
|
70
76
|
inputToken: tokenAddress,
|
|
71
77
|
outputToken: ZERO_ADDRESS,
|
|
@@ -75,7 +81,6 @@ export async function flapPrivateSellMerkle(params) {
|
|
|
75
81
|
});
|
|
76
82
|
const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
|
|
77
83
|
const signedTxs = [];
|
|
78
|
-
const currentNonce = await wallet.getNonce();
|
|
79
84
|
signedTxs.push(await wallet.signTransaction({
|
|
80
85
|
...unsigned,
|
|
81
86
|
from: wallet.address,
|
|
@@ -107,29 +112,35 @@ export async function flapBatchPrivateBuyMerkle(params) {
|
|
|
107
112
|
}
|
|
108
113
|
const { chainId, provider } = createMerkleContext(chain, config);
|
|
109
114
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
110
|
-
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
111
|
-
const signedTxs = [];
|
|
112
|
-
const nonceManager = new NonceManager(provider);
|
|
113
115
|
const wallets = privateKeys.map(k => new Wallet(k, provider));
|
|
114
116
|
const originalAmountsWei = amountsIn.map(a => ethers.parseEther(a));
|
|
115
117
|
// ✅ 利润提取配置
|
|
116
118
|
const extractProfit = shouldExtractProfit(config);
|
|
117
119
|
const { totalProfit, remainingAmounts } = calculateBatchProfit(originalAmountsWei, config);
|
|
118
|
-
const actualAmountsWei = remainingAmounts;
|
|
120
|
+
const actualAmountsWei = remainingAmounts;
|
|
119
121
|
const maxFundsIndex = findMaxIndex(originalAmountsWei);
|
|
120
122
|
const minOuts = resolveBatchMinOutputs(minOutputAmounts, wallets.length);
|
|
121
123
|
const portals = wallets.map(w => new ethers.Contract(portalAddr, PORTAL_ABI, w));
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
// ✅ 并行获取 gasPrice、所有 nonces 和构建未签名交易
|
|
125
|
+
const [gasPrice, initialNonces, unsignedList] = await Promise.all([
|
|
126
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
127
|
+
Promise.all(wallets.map(w => w.getNonce())),
|
|
128
|
+
Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
|
|
129
|
+
inputToken: ZERO_ADDRESS,
|
|
130
|
+
outputToken: tokenAddress,
|
|
131
|
+
inputAmount: actualAmountsWei[i],
|
|
132
|
+
minOutputAmount: minOuts[i],
|
|
133
|
+
permitData: '0x',
|
|
134
|
+
}, { value: actualAmountsWei[i] })))
|
|
135
|
+
]);
|
|
136
|
+
// ✅ 为需要支付利润的钱包预留额外 nonce
|
|
137
|
+
const nonces = initialNonces.map((n, i) => {
|
|
138
|
+
// 如果这个钱包需要支付利润,它的主交易 nonce 不变,利润交易用 nonce+1
|
|
139
|
+
return n;
|
|
140
|
+
});
|
|
130
141
|
const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
|
|
131
142
|
const gasLimits = new Array(wallets.length).fill(gasLimit);
|
|
132
|
-
|
|
143
|
+
// ✅ 并行签名所有交易
|
|
133
144
|
const signedList = await signBatchTransactions({
|
|
134
145
|
unsignedList,
|
|
135
146
|
wallets,
|
|
@@ -140,20 +151,21 @@ export async function flapBatchPrivateBuyMerkle(params) {
|
|
|
140
151
|
config,
|
|
141
152
|
values: actualAmountsWei
|
|
142
153
|
});
|
|
143
|
-
signedTxs
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
wallets
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
const signedTxs = [...signedList];
|
|
155
|
+
// 添加利润交易(使用 nonce + 1)
|
|
156
|
+
if (extractProfit && totalProfit > 0n && maxFundsIndex >= 0) {
|
|
157
|
+
const profitNonce = initialNonces[maxFundsIndex] + 1;
|
|
158
|
+
const profitTx = await wallets[maxFundsIndex].signTransaction({
|
|
159
|
+
to: getProfitRecipient(),
|
|
160
|
+
value: totalProfit,
|
|
161
|
+
nonce: profitNonce,
|
|
162
|
+
gasPrice,
|
|
163
|
+
gasLimit: 21000n,
|
|
164
|
+
chainId,
|
|
165
|
+
type: getTxType(config)
|
|
166
|
+
});
|
|
167
|
+
signedTxs.push(profitTx);
|
|
168
|
+
}
|
|
157
169
|
return { signedTransactions: signedTxs };
|
|
158
170
|
}
|
|
159
171
|
/**
|
|
@@ -166,34 +178,30 @@ export async function flapBatchPrivateSellMerkle(params) {
|
|
|
166
178
|
}
|
|
167
179
|
const { chainId, provider } = createMerkleContext(chain, config);
|
|
168
180
|
const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
|
|
169
|
-
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
170
|
-
const signedTxs = [];
|
|
171
|
-
const nonceManager = new NonceManager(provider);
|
|
172
181
|
const wallets = privateKeys.map(k => new Wallet(k, provider));
|
|
173
182
|
const amountsWei = amounts.map(a => ethers.parseUnits(a, 18));
|
|
174
|
-
// ✅ 自动获取报价以计算预期收益和利润
|
|
175
183
|
const portal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
const portals = wallets.map(w => new ethers.Contract(portalAddr, PORTAL_ABI, w));
|
|
185
|
+
// ✅ 并行获取 gasPrice、所有 nonces 和所有报价
|
|
186
|
+
const [gasPrice, initialNonces, quotedOutputs] = await Promise.all([
|
|
187
|
+
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
188
|
+
Promise.all(wallets.map(w => w.getNonce())),
|
|
189
|
+
Promise.all(amountsWei.map(amount => portal.quoteExactInput.staticCall({
|
|
190
|
+
inputToken: tokenAddress,
|
|
191
|
+
outputToken: ZERO_ADDRESS,
|
|
192
|
+
inputAmount: amount
|
|
193
|
+
}).catch(() => 0n)))
|
|
194
|
+
]);
|
|
195
|
+
// 计算 minOuts
|
|
186
196
|
let minOuts;
|
|
187
197
|
if (minOutputAmounts && minOutputAmounts.length === wallets.length) {
|
|
188
|
-
// 用户提供了 minOutputAmounts,优先使用
|
|
189
198
|
minOuts = minOutputAmounts.map(m => typeof m === 'string' ? ethers.parseEther(m) : m);
|
|
190
199
|
}
|
|
191
200
|
else {
|
|
192
|
-
// 使用报价结果作为 minOutputAmount(保守起见,使用 95% 的报价金额)
|
|
193
201
|
minOuts = quotedOutputs.map(quoted => quoted * 95n / 100n);
|
|
194
202
|
}
|
|
195
|
-
|
|
196
|
-
const unsignedList = await Promise.all(portals.map((
|
|
203
|
+
// ✅ 并行构建未签名交易
|
|
204
|
+
const unsignedList = await Promise.all(portals.map((p, i) => p.swapExactInput.populateTransaction({
|
|
197
205
|
inputToken: tokenAddress,
|
|
198
206
|
outputToken: ZERO_ADDRESS,
|
|
199
207
|
inputAmount: amountsWei[i],
|
|
@@ -204,29 +212,31 @@ export async function flapBatchPrivateSellMerkle(params) {
|
|
|
204
212
|
const { totalProfit, maxRevenueIndex } = summarizeSellProfits(quotedOutputs, extractProfit, config);
|
|
205
213
|
const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
|
|
206
214
|
const gasLimits = new Array(wallets.length).fill(gasLimit);
|
|
207
|
-
|
|
215
|
+
// ✅ 并行签名所有卖出交易
|
|
208
216
|
const signedList = await signBatchTransactions({
|
|
209
217
|
unsignedList,
|
|
210
218
|
wallets,
|
|
211
|
-
nonces,
|
|
219
|
+
nonces: initialNonces,
|
|
212
220
|
gasLimits,
|
|
213
221
|
gasPrice,
|
|
214
222
|
chainId,
|
|
215
223
|
config
|
|
216
224
|
});
|
|
217
|
-
signedTxs
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
wallets
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
const signedTxs = [...signedList];
|
|
226
|
+
// 添加利润交易(使用 nonce + 1)
|
|
227
|
+
if (extractProfit && totalProfit > 0n && maxRevenueIndex >= 0) {
|
|
228
|
+
const profitNonce = initialNonces[maxRevenueIndex] + 1;
|
|
229
|
+
const profitTx = await wallets[maxRevenueIndex].signTransaction({
|
|
230
|
+
to: getProfitRecipient(),
|
|
231
|
+
value: totalProfit,
|
|
232
|
+
nonce: profitNonce,
|
|
233
|
+
gasPrice,
|
|
234
|
+
gasLimit: 21000n,
|
|
235
|
+
chainId,
|
|
236
|
+
type: getTxType(config)
|
|
237
|
+
});
|
|
238
|
+
signedTxs.push(profitTx);
|
|
239
|
+
}
|
|
230
240
|
return { signedTransactions: signedTxs };
|
|
231
241
|
}
|
|
232
242
|
// ==================== 内部工具函数 ====================
|
|
@@ -354,20 +364,6 @@ function findMaxIndex(values) {
|
|
|
354
364
|
}
|
|
355
365
|
return maxIndex;
|
|
356
366
|
}
|
|
357
|
-
async function allocateProfitNonces(wallets, extractProfit, maxIndex, totalProfit, nonceManager) {
|
|
358
|
-
const nonces = [];
|
|
359
|
-
for (let i = 0; i < wallets.length; i++) {
|
|
360
|
-
if (extractProfit && totalProfit > 0n && i === maxIndex) {
|
|
361
|
-
const [nonce] = await nonceManager.getNextNonceBatch(wallets[i], 2);
|
|
362
|
-
nonces.push(nonce);
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
const nonce = await nonceManager.getNextNonce(wallets[i]);
|
|
366
|
-
nonces.push(nonce);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return nonces;
|
|
370
|
-
}
|
|
371
367
|
async function signBatchTransactions({ unsignedList, wallets, nonces, gasLimits, gasPrice, chainId, config, values }) {
|
|
372
368
|
return await Promise.all(unsignedList.map((unsigned, i) => {
|
|
373
369
|
const value = values ? values[i] : unsigned.value;
|
|
@@ -383,22 +379,6 @@ async function signBatchTransactions({ unsignedList, wallets, nonces, gasLimits,
|
|
|
383
379
|
});
|
|
384
380
|
}));
|
|
385
381
|
}
|
|
386
|
-
async function appendBatchProfitTransfer({ extractProfit, totalProfit, wallets, maxIndex, nonces, gasPrice, chainId, config, signedTxs }) {
|
|
387
|
-
if (!extractProfit || totalProfit === 0n || maxIndex < 0 || wallets.length === 0) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
const profitNonce = (nonces[maxIndex] ?? 0) + 1;
|
|
391
|
-
const profitTx = await wallets[maxIndex].signTransaction({
|
|
392
|
-
to: getProfitRecipient(),
|
|
393
|
-
value: totalProfit,
|
|
394
|
-
nonce: profitNonce,
|
|
395
|
-
gasPrice,
|
|
396
|
-
gasLimit: 21000n,
|
|
397
|
-
chainId,
|
|
398
|
-
type: getTxType(config)
|
|
399
|
-
});
|
|
400
|
-
signedTxs.push(profitTx);
|
|
401
|
-
}
|
|
402
382
|
function summarizeSellProfits(quotedOutputs, extractProfit, config) {
|
|
403
383
|
let totalProfit = 0n;
|
|
404
384
|
let maxRevenueIndex = -1;
|
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 } from './utils/erc20.js';
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solana SDK 常量配置
|
|
3
|
+
* @module sol/constants
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* RPC 节点配置
|
|
7
|
+
* 使用 Helius 主网(开发和生产都用主网)
|
|
8
|
+
*/
|
|
9
|
+
export declare const SOLANA_RPC: {
|
|
10
|
+
/** Helius 主网 RPC(需要替换 API Key) */
|
|
11
|
+
readonly MAINNET: "https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_KEY";
|
|
12
|
+
/** 公共主网 RPC(备用,有限速) */
|
|
13
|
+
readonly MAINNET_PUBLIC: "https://api.mainnet-beta.solana.com";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Jito Block Engine 配置
|
|
17
|
+
*/
|
|
18
|
+
export declare const JITO_CONFIG: {
|
|
19
|
+
/** Block Engine URL */
|
|
20
|
+
readonly BLOCK_ENGINE_URL: "https://mainnet.block-engine.jito.wtf";
|
|
21
|
+
/** Tip 账户列表(随机选择一个) */
|
|
22
|
+
readonly TIP_ACCOUNTS: readonly ["96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5", "HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U", "Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY", "ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49", "DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh", "ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt", "DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL", "3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"];
|
|
23
|
+
/** 最小 Tip(lamports) */
|
|
24
|
+
readonly MIN_TIP_LAMPORTS: 1000;
|
|
25
|
+
/** 默认 Tip(lamports)- 0.00001 SOL */
|
|
26
|
+
readonly DEFAULT_TIP_LAMPORTS: 10000;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Solana 系统程序地址
|
|
30
|
+
*/
|
|
31
|
+
export declare const SYSTEM_PROGRAMS: {
|
|
32
|
+
/** Token Program */
|
|
33
|
+
readonly TOKEN_PROGRAM: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
34
|
+
/** Token-2022 Program */
|
|
35
|
+
readonly TOKEN_2022_PROGRAM: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
36
|
+
/** Associated Token Account Program */
|
|
37
|
+
readonly ATA_PROGRAM: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
38
|
+
/** Metaplex Token Metadata Program */
|
|
39
|
+
readonly METADATA_PROGRAM: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
|
|
40
|
+
/** System Program */
|
|
41
|
+
readonly SYSTEM_PROGRAM: "11111111111111111111111111111111";
|
|
42
|
+
/** Rent Sysvar */
|
|
43
|
+
readonly RENT_SYSVAR: "SysvarRent111111111111111111111111111111111";
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Pump.fun 程序地址
|
|
47
|
+
*/
|
|
48
|
+
export declare const PUMP_PROGRAMS: {
|
|
49
|
+
/** Pump Program ID */
|
|
50
|
+
readonly PUMP_PROGRAM: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
|
|
51
|
+
/** Pump Swap Program ID */
|
|
52
|
+
readonly PUMP_SWAP_PROGRAM: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
|
|
53
|
+
/** Global Config */
|
|
54
|
+
readonly GLOBAL_CONFIG: "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf";
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Raydium 程序地址
|
|
58
|
+
*/
|
|
59
|
+
export declare const RAYDIUM_PROGRAMS: {
|
|
60
|
+
/** AMM Program ID */
|
|
61
|
+
readonly AMM_PROGRAM: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
|
|
62
|
+
/** CLMM Program ID */
|
|
63
|
+
readonly CLMM_PROGRAM: "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
|
|
64
|
+
/** LaunchLab Program ID */
|
|
65
|
+
readonly LAUNCHLAB_PROGRAM: "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj";
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Orca 程序地址
|
|
69
|
+
*/
|
|
70
|
+
export declare const ORCA_PROGRAMS: {
|
|
71
|
+
/** Whirlpool Program ID */
|
|
72
|
+
readonly WHIRLPOOL_PROGRAM: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Meteora 程序地址
|
|
76
|
+
*/
|
|
77
|
+
export declare const METEORA_PROGRAMS: {
|
|
78
|
+
/** DLMM Program ID */
|
|
79
|
+
readonly DLMM_PROGRAM: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
|
|
80
|
+
/** DAMM v2 Program ID */
|
|
81
|
+
readonly DAMM_V2_PROGRAM: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
|
|
82
|
+
/** DBC Program ID */
|
|
83
|
+
readonly DBC_PROGRAM: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN";
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* 常用代币地址
|
|
87
|
+
*/
|
|
88
|
+
export declare const TOKENS: {
|
|
89
|
+
/** Wrapped SOL */
|
|
90
|
+
readonly SOL: "So11111111111111111111111111111111111111112";
|
|
91
|
+
/** USDC */
|
|
92
|
+
readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
93
|
+
/** USDT */
|
|
94
|
+
readonly USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 交易默认配置
|
|
98
|
+
*/
|
|
99
|
+
export declare const TX_CONFIG: {
|
|
100
|
+
/** 默认滑点 1% */
|
|
101
|
+
readonly DEFAULT_SLIPPAGE: 1;
|
|
102
|
+
/** 最大滑点 50% */
|
|
103
|
+
readonly MAX_SLIPPAGE: 50;
|
|
104
|
+
/** 计算单元限制 */
|
|
105
|
+
readonly COMPUTE_UNIT_LIMIT: 200000;
|
|
106
|
+
/** 计算单元价格(microlamports) */
|
|
107
|
+
readonly COMPUTE_UNIT_PRICE: 50000;
|
|
108
|
+
/** 确认超时(毫秒) */
|
|
109
|
+
readonly CONFIRMATION_TIMEOUT: 60000;
|
|
110
|
+
/** 默认 commitment */
|
|
111
|
+
readonly DEFAULT_COMMITMENT: "confirmed";
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* 账户大小(用于计算租金)
|
|
115
|
+
*/
|
|
116
|
+
export declare const ACCOUNT_SIZE: {
|
|
117
|
+
/** Mint 账户大小 */
|
|
118
|
+
readonly MINT: 82;
|
|
119
|
+
/** Token 账户大小 */
|
|
120
|
+
readonly TOKEN_ACCOUNT: 165;
|
|
121
|
+
/** Metadata 账户大小(近似值) */
|
|
122
|
+
readonly METADATA: 679;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* SOL 单位换算
|
|
126
|
+
*/
|
|
127
|
+
export declare const SOL_DECIMALS = 9;
|
|
128
|
+
export declare const LAMPORTS_PER_SOL = 1000000000;
|
|
129
|
+
/**
|
|
130
|
+
* 将 SOL 转换为 lamports
|
|
131
|
+
*/
|
|
132
|
+
export declare function solToLamports(sol: number): bigint;
|
|
133
|
+
/**
|
|
134
|
+
* 将 lamports 转换为 SOL
|
|
135
|
+
*/
|
|
136
|
+
export declare function lamportsToSol(lamports: bigint): number;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solana SDK 常量配置
|
|
3
|
+
* @module sol/constants
|
|
4
|
+
*/
|
|
5
|
+
// ==================== RPC 配置 ====================
|
|
6
|
+
/**
|
|
7
|
+
* RPC 节点配置
|
|
8
|
+
* 使用 Helius 主网(开发和生产都用主网)
|
|
9
|
+
*/
|
|
10
|
+
export const SOLANA_RPC = {
|
|
11
|
+
/** Helius 主网 RPC(需要替换 API Key) */
|
|
12
|
+
MAINNET: 'https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_KEY',
|
|
13
|
+
/** 公共主网 RPC(备用,有限速) */
|
|
14
|
+
MAINNET_PUBLIC: 'https://api.mainnet-beta.solana.com',
|
|
15
|
+
};
|
|
16
|
+
// ==================== Jito Bundle 配置 ====================
|
|
17
|
+
/**
|
|
18
|
+
* Jito Block Engine 配置
|
|
19
|
+
*/
|
|
20
|
+
export const JITO_CONFIG = {
|
|
21
|
+
/** Block Engine URL */
|
|
22
|
+
BLOCK_ENGINE_URL: 'https://mainnet.block-engine.jito.wtf',
|
|
23
|
+
/** Tip 账户列表(随机选择一个) */
|
|
24
|
+
TIP_ACCOUNTS: [
|
|
25
|
+
'96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5',
|
|
26
|
+
'HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U',
|
|
27
|
+
'Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY',
|
|
28
|
+
'ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49',
|
|
29
|
+
'DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh',
|
|
30
|
+
'ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt',
|
|
31
|
+
'DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL',
|
|
32
|
+
'3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT',
|
|
33
|
+
],
|
|
34
|
+
/** 最小 Tip(lamports) */
|
|
35
|
+
MIN_TIP_LAMPORTS: 1000,
|
|
36
|
+
/** 默认 Tip(lamports)- 0.00001 SOL */
|
|
37
|
+
DEFAULT_TIP_LAMPORTS: 10000,
|
|
38
|
+
};
|
|
39
|
+
// ==================== 程序地址 ====================
|
|
40
|
+
/**
|
|
41
|
+
* Solana 系统程序地址
|
|
42
|
+
*/
|
|
43
|
+
export const SYSTEM_PROGRAMS = {
|
|
44
|
+
/** Token Program */
|
|
45
|
+
TOKEN_PROGRAM: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
|
|
46
|
+
/** Token-2022 Program */
|
|
47
|
+
TOKEN_2022_PROGRAM: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
|
|
48
|
+
/** Associated Token Account Program */
|
|
49
|
+
ATA_PROGRAM: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
50
|
+
/** Metaplex Token Metadata Program */
|
|
51
|
+
METADATA_PROGRAM: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
|
|
52
|
+
/** System Program */
|
|
53
|
+
SYSTEM_PROGRAM: '11111111111111111111111111111111',
|
|
54
|
+
/** Rent Sysvar */
|
|
55
|
+
RENT_SYSVAR: 'SysvarRent111111111111111111111111111111111',
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Pump.fun 程序地址
|
|
59
|
+
*/
|
|
60
|
+
export const PUMP_PROGRAMS = {
|
|
61
|
+
/** Pump Program ID */
|
|
62
|
+
PUMP_PROGRAM: '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P',
|
|
63
|
+
/** Pump Swap Program ID */
|
|
64
|
+
PUMP_SWAP_PROGRAM: 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA',
|
|
65
|
+
/** Global Config */
|
|
66
|
+
GLOBAL_CONFIG: '4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf',
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Raydium 程序地址
|
|
70
|
+
*/
|
|
71
|
+
export const RAYDIUM_PROGRAMS = {
|
|
72
|
+
/** AMM Program ID */
|
|
73
|
+
AMM_PROGRAM: '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8',
|
|
74
|
+
/** CLMM Program ID */
|
|
75
|
+
CLMM_PROGRAM: 'CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK',
|
|
76
|
+
/** LaunchLab Program ID */
|
|
77
|
+
LAUNCHLAB_PROGRAM: 'LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj',
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Orca 程序地址
|
|
81
|
+
*/
|
|
82
|
+
export const ORCA_PROGRAMS = {
|
|
83
|
+
/** Whirlpool Program ID */
|
|
84
|
+
WHIRLPOOL_PROGRAM: 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc',
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Meteora 程序地址
|
|
88
|
+
*/
|
|
89
|
+
export const METEORA_PROGRAMS = {
|
|
90
|
+
/** DLMM Program ID */
|
|
91
|
+
DLMM_PROGRAM: 'LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo',
|
|
92
|
+
/** DAMM v2 Program ID */
|
|
93
|
+
DAMM_V2_PROGRAM: 'cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG',
|
|
94
|
+
/** DBC Program ID */
|
|
95
|
+
DBC_PROGRAM: 'dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN',
|
|
96
|
+
};
|
|
97
|
+
// ==================== 常用代币地址 ====================
|
|
98
|
+
/**
|
|
99
|
+
* 常用代币地址
|
|
100
|
+
*/
|
|
101
|
+
export const TOKENS = {
|
|
102
|
+
/** Wrapped SOL */
|
|
103
|
+
SOL: 'So11111111111111111111111111111111111111112',
|
|
104
|
+
/** USDC */
|
|
105
|
+
USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
106
|
+
/** USDT */
|
|
107
|
+
USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
|
|
108
|
+
};
|
|
109
|
+
// ==================== 交易配置 ====================
|
|
110
|
+
/**
|
|
111
|
+
* 交易默认配置
|
|
112
|
+
*/
|
|
113
|
+
export const TX_CONFIG = {
|
|
114
|
+
/** 默认滑点 1% */
|
|
115
|
+
DEFAULT_SLIPPAGE: 1,
|
|
116
|
+
/** 最大滑点 50% */
|
|
117
|
+
MAX_SLIPPAGE: 50,
|
|
118
|
+
/** 计算单元限制 */
|
|
119
|
+
COMPUTE_UNIT_LIMIT: 200000,
|
|
120
|
+
/** 计算单元价格(microlamports) */
|
|
121
|
+
COMPUTE_UNIT_PRICE: 50000,
|
|
122
|
+
/** 确认超时(毫秒) */
|
|
123
|
+
CONFIRMATION_TIMEOUT: 60000,
|
|
124
|
+
/** 默认 commitment */
|
|
125
|
+
DEFAULT_COMMITMENT: 'confirmed',
|
|
126
|
+
};
|
|
127
|
+
// ==================== 账户大小 ====================
|
|
128
|
+
/**
|
|
129
|
+
* 账户大小(用于计算租金)
|
|
130
|
+
*/
|
|
131
|
+
export const ACCOUNT_SIZE = {
|
|
132
|
+
/** Mint 账户大小 */
|
|
133
|
+
MINT: 82,
|
|
134
|
+
/** Token 账户大小 */
|
|
135
|
+
TOKEN_ACCOUNT: 165,
|
|
136
|
+
/** Metadata 账户大小(近似值) */
|
|
137
|
+
METADATA: 679,
|
|
138
|
+
};
|
|
139
|
+
// ==================== 单位换算 ====================
|
|
140
|
+
/**
|
|
141
|
+
* SOL 单位换算
|
|
142
|
+
*/
|
|
143
|
+
export const SOL_DECIMALS = 9;
|
|
144
|
+
export const LAMPORTS_PER_SOL = 1000000000;
|
|
145
|
+
/**
|
|
146
|
+
* 将 SOL 转换为 lamports
|
|
147
|
+
*/
|
|
148
|
+
export function solToLamports(sol) {
|
|
149
|
+
return BigInt(Math.floor(sol * LAMPORTS_PER_SOL));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 将 lamports 转换为 SOL
|
|
153
|
+
*/
|
|
154
|
+
export function lamportsToSol(lamports) {
|
|
155
|
+
return Number(lamports) / LAMPORTS_PER_SOL;
|
|
156
|
+
}
|