four-flap-meme-sdk 4.3.18 → 4.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chains/robinhood/constants.d.ts +1 -0
- package/dist/chains/robinhood/constants.js +4 -1
- package/dist/chains/robinhood/longetf/launch.js +4 -4
- package/dist/chains/robinhood/pons-v2/launch.js +2 -2
- package/dist/core/constants/chains.d.ts +1 -3
- package/dist/core/constants/chains.js +10 -0
- package/dist/core/constants/gas-erc20-floor.test.js +14 -1
- package/dist/core/constants/gas.d.ts +7 -0
- package/dist/core/constants/gas.js +112 -12
- package/dist/core/constants/index.d.ts +1 -1
- package/dist/core/constants/index.js +1 -1
- package/dist/core/constants/profit.test-setup.js +1 -1
- package/dist/core/gas/profit-hop.js +5 -5
- package/dist/domains/dex/profit.js +3 -3
- package/dist/exports/root-foundations.d.ts +1 -1
- package/dist/exports/root-foundations.js +1 -1
- package/package.json +1 -1
|
@@ -29,6 +29,7 @@ export declare const LONGETF_DEPLOY_VAULT_GAS_LIMIT: 3000000n;
|
|
|
29
29
|
export declare const LONGETF_LAUNCH_GAS_LIMIT: 3000000n;
|
|
30
30
|
export declare const LONGETF_REGISTER_GAS_LIMIT: 500000n;
|
|
31
31
|
export declare const PONS_V2_LAUNCH_GAS_LIMIT: 3000000n;
|
|
32
|
+
export declare function robinhoodConfiguredGas(key: string, fallback: bigint): bigint;
|
|
32
33
|
/** Word index after the 4-byte selector in long.xyz create() template. */
|
|
33
34
|
export declare const LONGETF_LAUNCH_WORDS: {
|
|
34
35
|
readonly salt: 13;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Robinhood Chain 发币常量
|
|
3
3
|
*/
|
|
4
|
-
import { ADDRESSES, CHAINS, GAS_LIMITS } from '../../core/constants/index.js';
|
|
4
|
+
import { ADDRESSES, CHAINS, GAS_LIMITS, getChainGasNumber } from '../../core/constants/index.js';
|
|
5
5
|
export const ROBINHOOD_CHAIN_ID = CHAINS.ROBINHOOD.chainId;
|
|
6
6
|
export const ROBINHOOD_RPC_URL = CHAINS.ROBINHOOD.rpcUrls.default;
|
|
7
7
|
export const ROBINHOOD_EXPLORER = CHAINS.ROBINHOOD.explorer;
|
|
@@ -16,6 +16,9 @@ export const LONGETF_DEPLOY_VAULT_GAS_LIMIT = GAS_LIMITS.ROBINHOOD_LONGETF_DEPLO
|
|
|
16
16
|
export const LONGETF_LAUNCH_GAS_LIMIT = GAS_LIMITS.ROBINHOOD_LONGETF_LAUNCH;
|
|
17
17
|
export const LONGETF_REGISTER_GAS_LIMIT = GAS_LIMITS.ROBINHOOD_LONGETF_REGISTER;
|
|
18
18
|
export const PONS_V2_LAUNCH_GAS_LIMIT = GAS_LIMITS.ROBINHOOD_PONS_LAUNCH;
|
|
19
|
+
export function robinhoodConfiguredGas(key, fallback) {
|
|
20
|
+
return BigInt(getChainGasNumber(ROBINHOOD_CHAIN_ID, key, Number(fallback)));
|
|
21
|
+
}
|
|
19
22
|
/** Word index after the 4-byte selector in long.xyz create() template. */
|
|
20
23
|
export const LONGETF_LAUNCH_WORDS = {
|
|
21
24
|
salt: 13,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 必须逐笔等确认,不能一次签完再广播。
|
|
4
4
|
*/
|
|
5
5
|
import { JsonRpcProvider } from 'ethers';
|
|
6
|
-
import { LONGETF_DEPLOY_VAULT_GAS_LIMIT, LONGETF_FACTORY, LONGETF_LAUNCH_GAS_LIMIT, LONGETF_REGISTER_GAS_LIMIT, LONG_XYZ_LAUNCHER, ROBINHOOD_CHAIN_ID, ROBINHOOD_RPC_URL, } from '../constants.js';
|
|
6
|
+
import { LONGETF_DEPLOY_VAULT_GAS_LIMIT, LONGETF_FACTORY, LONGETF_LAUNCH_GAS_LIMIT, LONGETF_REGISTER_GAS_LIMIT, robinhoodConfiguredGas, LONG_XYZ_LAUNCHER, ROBINHOOD_CHAIN_ID, ROBINHOOD_RPC_URL, } from '../constants.js';
|
|
7
7
|
import { signRobinhoodTx } from '../sign.js';
|
|
8
8
|
import { LONGETF_VAULT_INITCODE } from './assets.js';
|
|
9
9
|
import { encodeLongetfDeployVault, encodeLongetfIsTickerAvailable, encodeLongetfRegister, longetfVaultInitCodeHash, mineLongetfVaultSalt, patchLongetfLaunchCalldata, } from './encode.js';
|
|
@@ -25,7 +25,7 @@ export async function signLongetfDeployVault(params) {
|
|
|
25
25
|
privateKey: params.privateKey,
|
|
26
26
|
to: LONGETF_FACTORY,
|
|
27
27
|
data: encodeLongetfDeployVault(params.salt, params.creator, initCode),
|
|
28
|
-
gasLimit: LONGETF_DEPLOY_VAULT_GAS_LIMIT,
|
|
28
|
+
gasLimit: robinhoodConfiguredGas('longetf_deploy_vault_gas', LONGETF_DEPLOY_VAULT_GAS_LIMIT),
|
|
29
29
|
gasPrice: params.gasPrice,
|
|
30
30
|
nonce: params.nonce,
|
|
31
31
|
});
|
|
@@ -42,7 +42,7 @@ export async function signLongetfLaunch(params) {
|
|
|
42
42
|
vault: params.vault,
|
|
43
43
|
metaUri: params.metaUri,
|
|
44
44
|
}, params.launchTemplate),
|
|
45
|
-
gasLimit: LONGETF_LAUNCH_GAS_LIMIT,
|
|
45
|
+
gasLimit: robinhoodConfiguredGas('longetf_launch_gas', LONGETF_LAUNCH_GAS_LIMIT),
|
|
46
46
|
gasPrice: params.gasPrice,
|
|
47
47
|
nonce: params.nonce,
|
|
48
48
|
});
|
|
@@ -53,7 +53,7 @@ export async function signLongetfRegister(params) {
|
|
|
53
53
|
privateKey: params.privateKey,
|
|
54
54
|
to: LONGETF_FACTORY,
|
|
55
55
|
data: encodeLongetfRegister(params.token, params.vault),
|
|
56
|
-
gasLimit: LONGETF_REGISTER_GAS_LIMIT,
|
|
56
|
+
gasLimit: robinhoodConfiguredGas('longetf_register_gas', LONGETF_REGISTER_GAS_LIMIT),
|
|
57
57
|
gasPrice: params.gasPrice,
|
|
58
58
|
nonce: params.nonce,
|
|
59
59
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* pons v2 发币:读 launchFee + expectedEconomics,再签 launchToken 或 launchAndBuy
|
|
3
3
|
*/
|
|
4
4
|
import { Contract, JsonRpcProvider, Wallet, ZeroAddress } from 'ethers';
|
|
5
|
-
import { PONS_V2_FACTORY, PONS_V2_FACTORY_ABI, PONS_V2_LAUNCH_GAS_LIMIT, ROBINHOOD_CHAIN_ID, ROBINHOOD_RPC_URL, } from '../constants.js';
|
|
5
|
+
import { PONS_V2_FACTORY, PONS_V2_FACTORY_ABI, PONS_V2_LAUNCH_GAS_LIMIT, robinhoodConfiguredGas, ROBINHOOD_CHAIN_ID, ROBINHOOD_RPC_URL, } from '../constants.js';
|
|
6
6
|
import { signRobinhoodTx } from '../sign.js';
|
|
7
7
|
import { buildPonsV2LaunchCall, encodePonsV2PreviewLaunchEconomics, randomPonsV2Salt, } from './encode.js';
|
|
8
8
|
export async function getPonsV2LaunchFee(rpcUrl = ROBINHOOD_RPC_URL) {
|
|
@@ -92,7 +92,7 @@ export async function signPonsV2Launch(params) {
|
|
|
92
92
|
to: call.to,
|
|
93
93
|
data: call.data,
|
|
94
94
|
value: call.value,
|
|
95
|
-
gasLimit: PONS_V2_LAUNCH_GAS_LIMIT,
|
|
95
|
+
gasLimit: robinhoodConfiguredGas('pons_launch_gas', PONS_V2_LAUNCH_GAS_LIMIT),
|
|
96
96
|
gasPrice: params.gasPrice,
|
|
97
97
|
nonce: params.nonce,
|
|
98
98
|
});
|
|
@@ -156,7 +156,5 @@ export declare function isEniChain(chainId: number): boolean;
|
|
|
156
156
|
* 判断是否为 Robinhood Chain
|
|
157
157
|
*/
|
|
158
158
|
export declare function isRobinhoodChain(chainId: number): boolean;
|
|
159
|
-
|
|
160
|
-
* 获取确认超时时间
|
|
161
|
-
*/
|
|
159
|
+
export declare function setConfirmationTimeoutOverride(chainId: number, ms: number | null): void;
|
|
162
160
|
export declare function getConfirmationTimeout(chainId: number): number;
|
|
@@ -199,6 +199,16 @@ export function isRobinhoodChain(chainId) {
|
|
|
199
199
|
/**
|
|
200
200
|
* 获取确认超时时间
|
|
201
201
|
*/
|
|
202
|
+
const confirmationTimeoutOverride = new Map();
|
|
203
|
+
export function setConfirmationTimeoutOverride(chainId, ms) {
|
|
204
|
+
if (ms != null && Number.isFinite(ms) && ms > 0)
|
|
205
|
+
confirmationTimeoutOverride.set(chainId, Math.floor(ms));
|
|
206
|
+
else
|
|
207
|
+
confirmationTimeoutOverride.delete(chainId);
|
|
208
|
+
}
|
|
202
209
|
export function getConfirmationTimeout(chainId) {
|
|
210
|
+
const custom = confirmationTimeoutOverride.get(chainId);
|
|
211
|
+
if (custom && custom > 0)
|
|
212
|
+
return custom;
|
|
203
213
|
return getChainById(chainId)?.confirmationTimeout ?? 60000;
|
|
204
214
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import { calculateGasLimit } from '../../bundle/internal.js';
|
|
3
|
-
import {
|
|
3
|
+
import { CHAINS } from './chains.js';
|
|
4
|
+
import { GAS_LIMITS, floorErc20TransferGasLimit, getTransferGasLimit, setNativeTransferGasLimits } from './gas.js';
|
|
5
|
+
describe('getTransferGasLimit', () => {
|
|
6
|
+
it('默认不改各链;库表灌入后只改对应链', () => {
|
|
7
|
+
expect(getTransferGasLimit(CHAINS.BSC.chainId, true)).toBe(21055n);
|
|
8
|
+
expect(getTransferGasLimit(CHAINS.ROBINHOOD.chainId, true)).toBe(21055n);
|
|
9
|
+
expect(getTransferGasLimit(CHAINS.XLAYER.chainId, true)).toBe(GAS_LIMITS.XLAYER_NATIVE_TRANSFER);
|
|
10
|
+
setNativeTransferGasLimits({ [CHAINS.ROBINHOOD.chainId]: 30000 });
|
|
11
|
+
expect(getTransferGasLimit(CHAINS.ROBINHOOD.chainId, true)).toBe(30000n);
|
|
12
|
+
expect(getTransferGasLimit(CHAINS.BSC.chainId, true)).toBe(21055n);
|
|
13
|
+
setNativeTransferGasLimits(null);
|
|
14
|
+
expect(getTransferGasLimit(CHAINS.ROBINHOOD.chainId, true)).toBe(21055n);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
4
17
|
describe('floorErc20TransferGasLimit', () => {
|
|
5
18
|
it('raises USDT-era 65000 to SPCXB-safe 120000', () => {
|
|
6
19
|
expect(floorErc20TransferGasLimit(65000)).toBe(GAS_LIMITS.ERC20_TRANSFER);
|
|
@@ -72,6 +72,13 @@ export declare const V3_FEE_TIERS: {
|
|
|
72
72
|
};
|
|
73
73
|
export type GasLimitKey = keyof typeof GAS_LIMITS;
|
|
74
74
|
export type V3FeeTier = (typeof V3_FEE_TIERS)[keyof typeof V3_FEE_TIERS];
|
|
75
|
+
export declare function setNativeTransferGasLimits(limits: Record<number, bigint | number> | null | undefined): void;
|
|
76
|
+
/** 前端把 chain_gas_configs 灌进来。null 清掉该链覆盖。 */
|
|
77
|
+
export declare function setChainGasConfigs(chainId: number, values: Record<string, string | number> | null | undefined): void;
|
|
78
|
+
export declare function getChainGasNumber(chainId: number, key: string, fallback: number): number;
|
|
79
|
+
export declare function getConfiguredProfitHopCount(chainId: number): number;
|
|
80
|
+
export declare function chainRequiresProfitHop(chainId: number): boolean;
|
|
81
|
+
export declare function getBribeGasLimit(chainId?: number): bigint;
|
|
75
82
|
/**
|
|
76
83
|
* 根据链和交易类型计算 gas limit
|
|
77
84
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Gas 限制常量
|
|
3
3
|
* ⚠️ 禁止在代码中硬编码 gas limit,必须使用此处定义的常量
|
|
4
4
|
*/
|
|
5
|
-
import { CHAINS } from './chains.js';
|
|
5
|
+
import { CHAINS, setConfirmationTimeoutOverride } from './chains.js';
|
|
6
6
|
// ============================================================================
|
|
7
7
|
// 通用 Gas 限制
|
|
8
8
|
// ============================================================================
|
|
@@ -86,6 +86,111 @@ export const V3_FEE_TIERS = {
|
|
|
86
86
|
/** 1% - 低流动性币对 */
|
|
87
87
|
HIGH: 10000,
|
|
88
88
|
};
|
|
89
|
+
/** 库表下发的每链原生转账 gas。空表示清掉,回到代码里的默认值。 */
|
|
90
|
+
const nativeTransferGasOverride = new Map();
|
|
91
|
+
export function setNativeTransferGasLimits(limits) {
|
|
92
|
+
nativeTransferGasOverride.clear();
|
|
93
|
+
if (!limits)
|
|
94
|
+
return;
|
|
95
|
+
for (const [key, value] of Object.entries(limits)) {
|
|
96
|
+
const chainId = Number(key);
|
|
97
|
+
try {
|
|
98
|
+
const gas = BigInt(value);
|
|
99
|
+
if (Number.isFinite(chainId) && gas > 0n)
|
|
100
|
+
nativeTransferGasOverride.set(chainId, gas);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// 非法数字跳过
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function resolveNativeTransferGas(chainId) {
|
|
108
|
+
const custom = nativeTransferGasOverride.get(chainId);
|
|
109
|
+
if (custom)
|
|
110
|
+
return custom;
|
|
111
|
+
if (chainId === CHAINS.XLAYER.chainId)
|
|
112
|
+
return GAS_LIMITS.XLAYER_NATIVE_TRANSFER;
|
|
113
|
+
return GAS_LIMITS.NATIVE_TRANSFER;
|
|
114
|
+
}
|
|
115
|
+
const erc20TransferGasOverride = new Map();
|
|
116
|
+
const bribeGasOverride = new Map();
|
|
117
|
+
const profitHopCountOverride = new Map();
|
|
118
|
+
const requireProfitHopOverride = new Map();
|
|
119
|
+
const chainGasNumberOverride = new Map();
|
|
120
|
+
function positiveNumber(value) {
|
|
121
|
+
const n = Number(value);
|
|
122
|
+
if (!Number.isFinite(n) || n <= 0)
|
|
123
|
+
return null;
|
|
124
|
+
return n;
|
|
125
|
+
}
|
|
126
|
+
/** 前端把 chain_gas_configs 灌进来。null 清掉该链覆盖。 */
|
|
127
|
+
export function setChainGasConfigs(chainId, values) {
|
|
128
|
+
if (!Number.isFinite(chainId))
|
|
129
|
+
return;
|
|
130
|
+
if (!values) {
|
|
131
|
+
nativeTransferGasOverride.delete(chainId);
|
|
132
|
+
erc20TransferGasOverride.delete(chainId);
|
|
133
|
+
bribeGasOverride.delete(chainId);
|
|
134
|
+
profitHopCountOverride.delete(chainId);
|
|
135
|
+
requireProfitHopOverride.delete(chainId);
|
|
136
|
+
chainGasNumberOverride.delete(chainId);
|
|
137
|
+
setConfirmationTimeoutOverride(chainId, null);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const bag = {};
|
|
141
|
+
for (const [key, value] of Object.entries(values)) {
|
|
142
|
+
const n = positiveNumber(value);
|
|
143
|
+
if (n != null)
|
|
144
|
+
bag[key] = n;
|
|
145
|
+
}
|
|
146
|
+
chainGasNumberOverride.set(chainId, bag);
|
|
147
|
+
const native = bag.native_transfer_gas;
|
|
148
|
+
if (native)
|
|
149
|
+
nativeTransferGasOverride.set(chainId, BigInt(Math.floor(native)));
|
|
150
|
+
else
|
|
151
|
+
nativeTransferGasOverride.delete(chainId);
|
|
152
|
+
const erc20 = bag.erc20_transfer_gas;
|
|
153
|
+
if (erc20)
|
|
154
|
+
erc20TransferGasOverride.set(chainId, BigInt(Math.floor(erc20)));
|
|
155
|
+
else
|
|
156
|
+
erc20TransferGasOverride.delete(chainId);
|
|
157
|
+
const bribe = bag.bribe_gas;
|
|
158
|
+
if (bribe)
|
|
159
|
+
bribeGasOverride.set(chainId, BigInt(Math.floor(bribe)));
|
|
160
|
+
else
|
|
161
|
+
bribeGasOverride.delete(chainId);
|
|
162
|
+
const hops = bag.profit_hop_count;
|
|
163
|
+
if (hops)
|
|
164
|
+
profitHopCountOverride.set(chainId, Math.floor(hops));
|
|
165
|
+
else
|
|
166
|
+
profitHopCountOverride.delete(chainId);
|
|
167
|
+
if (bag.require_profit_hop != null)
|
|
168
|
+
requireProfitHopOverride.set(chainId, bag.require_profit_hop !== 0);
|
|
169
|
+
else
|
|
170
|
+
requireProfitHopOverride.delete(chainId);
|
|
171
|
+
setConfirmationTimeoutOverride(chainId, bag.confirmation_timeout_ms ?? null);
|
|
172
|
+
}
|
|
173
|
+
export function getChainGasNumber(chainId, key, fallback) {
|
|
174
|
+
const n = chainGasNumberOverride.get(chainId)?.[key];
|
|
175
|
+
return n != null && n > 0 ? n : fallback;
|
|
176
|
+
}
|
|
177
|
+
export function getConfiguredProfitHopCount(chainId) {
|
|
178
|
+
return profitHopCountOverride.get(chainId) ?? 2;
|
|
179
|
+
}
|
|
180
|
+
export function chainRequiresProfitHop(chainId) {
|
|
181
|
+
const custom = requireProfitHopOverride.get(chainId);
|
|
182
|
+
if (custom != null)
|
|
183
|
+
return custom;
|
|
184
|
+
return chainId === CHAINS.BSC.chainId;
|
|
185
|
+
}
|
|
186
|
+
export function getBribeGasLimit(chainId) {
|
|
187
|
+
if (chainId != null) {
|
|
188
|
+
const custom = bribeGasOverride.get(chainId);
|
|
189
|
+
if (custom)
|
|
190
|
+
return custom;
|
|
191
|
+
}
|
|
192
|
+
return GAS_LIMITS.BRIBE;
|
|
193
|
+
}
|
|
89
194
|
// ============================================================================
|
|
90
195
|
// 工具函数
|
|
91
196
|
// ============================================================================
|
|
@@ -93,18 +198,14 @@ export const V3_FEE_TIERS = {
|
|
|
93
198
|
* 根据链和交易类型计算 gas limit
|
|
94
199
|
*/
|
|
95
200
|
export function calculateGasLimit(chainId, isNative, hasHops = false, hopCount = 0) {
|
|
96
|
-
// XLayer 原生转账需要更多 gas
|
|
97
|
-
if (chainId === CHAINS.XLAYER.chainId && isNative) {
|
|
98
|
-
return GAS_LIMITS.XLAYER_NATIVE_TRANSFER;
|
|
99
|
-
}
|
|
100
201
|
// 有多跳时,基础 gas + 每跳额外 gas
|
|
101
202
|
if (hasHops && hopCount > 0) {
|
|
102
|
-
const hopGas = isNative ?
|
|
203
|
+
const hopGas = isNative ? resolveNativeTransferGas(chainId) : GAS_LIMITS.ERC20_TRANSFER;
|
|
103
204
|
return GAS_LIMITS.TRADE + hopGas * BigInt(hopCount);
|
|
104
205
|
}
|
|
105
|
-
//
|
|
206
|
+
// 普通转账。每链额度优先用 setNativeTransferGasLimits 灌进来的库表值。
|
|
106
207
|
if (isNative) {
|
|
107
|
-
return
|
|
208
|
+
return resolveNativeTransferGas(chainId);
|
|
108
209
|
}
|
|
109
210
|
return GAS_LIMITS.ERC20_TRANSFER;
|
|
110
211
|
}
|
|
@@ -114,10 +215,9 @@ export function calculateGasLimit(chainId, isNative, hasHops = false, hopCount =
|
|
|
114
215
|
* @param isNative 是否原生代币
|
|
115
216
|
*/
|
|
116
217
|
export function getTransferGasLimit(chainId, isNative) {
|
|
117
|
-
if (isNative)
|
|
118
|
-
return chainId
|
|
119
|
-
|
|
120
|
-
return GAS_LIMITS.ERC20_TRANSFER;
|
|
218
|
+
if (isNative)
|
|
219
|
+
return resolveNativeTransferGas(chainId);
|
|
220
|
+
return erc20TransferGasOverride.get(chainId) ?? GAS_LIMITS.ERC20_TRANSFER;
|
|
121
221
|
}
|
|
122
222
|
/** 归集/分发 ERC20:UI 常传 65000(USDT),SPCXB/税币 transfer 会 OOG。 */
|
|
123
223
|
export function floorErc20TransferGasLimit(requested) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* const wbnb = ADDRESSES.BSC.WBNB;
|
|
10
10
|
*/
|
|
11
11
|
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, isRobinhoodChain, getConfirmationTimeout, type ChainKey, type ChainConfig, } from './chains.js';
|
|
12
|
-
export { GAS_LIMITS, GAS_CONFIG, V3_FEE_TIERS, calculateGasLimit, getTransferGasLimit, floorErc20TransferGasLimit, type GasLimitKey, type V3FeeTier, } from './gas.js';
|
|
12
|
+
export { GAS_LIMITS, GAS_CONFIG, V3_FEE_TIERS, calculateGasLimit, getTransferGasLimit, setNativeTransferGasLimits, setChainGasConfigs, getChainGasNumber, getConfiguredProfitHopCount, chainRequiresProfitHop, getBribeGasLimit, floorErc20TransferGasLimit, type GasLimitKey, type V3FeeTier, } from './gas.js';
|
|
13
13
|
export { QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, getQuoteChainKey, type QuoteConfigChain } from './quote.js';
|
|
14
14
|
export { applySlippageBps, reverseSlippageBps } from './slippage.js';
|
|
15
15
|
/** Flap 链标识(与 `FlapPortal` 一致,供子路径 `./constants` 使用) */
|
|
@@ -15,7 +15,7 @@ export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isK
|
|
|
15
15
|
// ============================================================================
|
|
16
16
|
// Gas 常量
|
|
17
17
|
// ============================================================================
|
|
18
|
-
export { GAS_LIMITS, GAS_CONFIG, V3_FEE_TIERS, calculateGasLimit, getTransferGasLimit, floorErc20TransferGasLimit, } from './gas.js';
|
|
18
|
+
export { GAS_LIMITS, GAS_CONFIG, V3_FEE_TIERS, calculateGasLimit, getTransferGasLimit, setNativeTransferGasLimits, setChainGasConfigs, getChainGasNumber, getConfiguredProfitHopCount, chainRequiresProfitHop, getBribeGasLimit, floorErc20TransferGasLimit, } from './gas.js';
|
|
19
19
|
export { QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, getQuoteChainKey } from './quote.js';
|
|
20
20
|
export { applySlippageBps, reverseSlippageBps } from './slippage.js';
|
|
21
21
|
// ============================================================================
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Wallet } from 'ethers';
|
|
2
2
|
import { generateWallets } from '../wallet/generate.js';
|
|
3
|
-
import {
|
|
3
|
+
import { chainRequiresProfitHop, getConfiguredProfitHopCount, getTransferGasLimit } from '../constants/index.js';
|
|
4
4
|
import { NonceManager } from '../nonce/nonce-manager.js';
|
|
5
5
|
import { buildGasFields } from './bundle-gas.js';
|
|
6
6
|
export const PROFIT_HOP_COUNT = 2;
|
|
7
|
-
const CHAINS_REQUIRE_HOP = [CHAINS.BSC.chainId];
|
|
8
7
|
export async function buildProfitHopTransactions(config) {
|
|
9
|
-
const { provider, payerWallet, profitAmount, profitRecipient,
|
|
8
|
+
const { provider, payerWallet, profitAmount, profitRecipient, gasPrice, chainId, txType, startNonce, } = config;
|
|
10
9
|
if (profitAmount <= 0n) {
|
|
11
10
|
return { signedTransactions: [], hopWallets: [], totalNonceUsed: 0 };
|
|
12
11
|
}
|
|
13
|
-
const nativeTransferGasLimit =
|
|
12
|
+
const nativeTransferGasLimit = getTransferGasLimit(chainId, true);
|
|
14
13
|
const signedTxs = [];
|
|
15
14
|
const nonceManager = new NonceManager(provider);
|
|
16
15
|
const payerNonce = startNonce ?? (await nonceManager.getNextNonce(payerWallet));
|
|
17
|
-
const needHop =
|
|
16
|
+
const needHop = chainRequiresProfitHop(chainId);
|
|
17
|
+
const hopCount = config.hopCount ?? getConfiguredProfitHopCount(chainId);
|
|
18
18
|
const gasFields = buildGasFields(txType, gasPrice);
|
|
19
19
|
if (!needHop) {
|
|
20
20
|
const directTx = await payerWallet.signTransaction({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { BLOCKRAZOR_BUILDER_EOA, GAS_LIMITS, getProfitRateBps, getProfitRecipient } from '../../core/constants/index.js';
|
|
3
|
-
import { buildGasFields, buildProfitHopTransactions
|
|
2
|
+
import { BLOCKRAZOR_BUILDER_EOA, GAS_LIMITS, getConfiguredProfitHopCount, getProfitRateBps, getProfitRecipient } from '../../core/constants/index.js';
|
|
3
|
+
import { buildGasFields, buildProfitHopTransactions } from '../../utils/bundle-helpers.js';
|
|
4
4
|
/**
|
|
5
5
|
* ✅ 找到金额最大的钱包索引(和 core.ts 逻辑一致)
|
|
6
6
|
*/
|
|
@@ -32,7 +32,7 @@ export async function buildProfitTransactionWithHops(provider, wallet, profitAmo
|
|
|
32
32
|
payerWallet: wallet,
|
|
33
33
|
profitAmount: profitAmountWei,
|
|
34
34
|
profitRecipient: profitRecipient || getProfitRecipient(),
|
|
35
|
-
hopCount:
|
|
35
|
+
hopCount: getConfiguredProfitHopCount(chainId),
|
|
36
36
|
gasPrice,
|
|
37
37
|
chainId,
|
|
38
38
|
txType,
|
|
@@ -8,7 +8,7 @@ export * as chains from '../chains/index.js';
|
|
|
8
8
|
export * as Abis from '../abis/index.js';
|
|
9
9
|
export { getErrorMessageFromUnknown, normalizeUnknownError, noopSdkLogger, consoleSdkLogger, buildTransactionRequest, type NormalizedErrorShape, type SdkLogger, type Aggregate3CallResult, type EnsureAllowanceResult, type EnsureAllowanceBatchItemResult, type BuildTxRequestParams, type HoldersMakerChain, type HoldersMakerTradeType, type BaseTokenType, type HoldersMakerConfig, type HoldersMakerParams, type TransactionLayer, type BatchResult, type BatchResult as HoldersMakerBatchResult, type HoldersMakerResult, type DexConfig, type ChainDexConfig, type PoolPairInfo, type V3PoolInfo, type DexPoolInfo, type BestPoolInfo, type LPPlatform, type LPInfo, type InspectOptions, type BundleSubmitResult, type SignedTransactionsResult, type DisperseParams, type AirdropDisperseSignParams, type SweepParams, type AirdropSweepSignParams, type PrivateSaleSignConfig, type PrivateSaleTransferParams, type BatchPrivateSaleParams, type PrivateSaleResult, type ApproveTokenBatchParams, type ApproveTokenBatchRawParams, type ApproveTokenBatchResult, type ApproveTokenBatchSignResult, type SupportedChain, type QuoteParams, type QuoteResult, } from '../core/index.js';
|
|
10
10
|
export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from '../abis/common.js';
|
|
11
|
-
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, isRobinhoodChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ADDRESSES, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders, setProfitRecipients, getProfitRecipient, getAllProfitRecipients, setProfitRates, getProfitRateBps, calculateProfitAmount, calculateBundleSwapRoundTripProfit, calculateProfitHopGasCost, setTransferFees, setTransferFeePerAddress, getTransferFeePerAddress, TRANSFER_FEE_PER_ADDRESS, setIroSubscribeFees, setIroSubscribeFeePerAddress, getIroSubscribeFeePerAddress, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
11
|
+
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, isRobinhoodChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, setNativeTransferGasLimits, setChainGasConfigs, getChainGasNumber, getConfiguredProfitHopCount, chainRequiresProfitHop, getBribeGasLimit, ADDRESSES, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders, setProfitRecipients, getProfitRecipient, getAllProfitRecipients, setProfitRates, getProfitRateBps, calculateProfitAmount, calculateBundleSwapRoundTripProfit, calculateProfitHopGasCost, setTransferFees, setTransferFeePerAddress, getTransferFeePerAddress, TRANSFER_FEE_PER_ADDRESS, setIroSubscribeFees, setIroSubscribeFeePerAddress, getIroSubscribeFeePerAddress, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
12
12
|
export { buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../utils/bundle-helpers.js';
|
|
13
13
|
export { isExclusiveOnChain, isExclusiveOffChain } from '../utils/mpcExclusive.js';
|
|
14
14
|
export { ensureSellApprovalV1, checkSellApprovalV1, ensureSellApprovalV2, checkSellApprovalV2, ensureSellApproval, checkSellApproval, ensureFlapSellApproval, checkFlapSellApproval, ensureFlapSellApprovalBatch, checkFlapSellApprovalBatch, checkAllowance, approveToken, checkAllowanceBatch, approveTokenBatch, checkAllowanceRaw, approveTokenRaw, checkAllowanceBatchRaw, approveTokenBatchRaw, } from '../core/erc20/index.js';
|
|
@@ -25,7 +25,7 @@ export {
|
|
|
25
25
|
// 链配置
|
|
26
26
|
CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, isRobinhoodChain, getConfirmationTimeout,
|
|
27
27
|
// Gas 常量
|
|
28
|
-
GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit,
|
|
28
|
+
GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, setNativeTransferGasLimits, setChainGasConfigs, getChainGasNumber, getConfiguredProfitHopCount, chainRequiresProfitHop, getBribeGasLimit,
|
|
29
29
|
// 合约地址
|
|
30
30
|
ADDRESSES, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders,
|
|
31
31
|
// 利润配置
|