four-flap-meme-sdk 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/__tests__/subpath-exports.test.js +34 -0
  2. package/dist/chains/index.d.ts +13 -0
  3. package/dist/chains/index.js +13 -0
  4. package/dist/chains/xlayer/eip7702/index.d.ts +2 -0
  5. package/dist/flap/index.d.ts +10 -0
  6. package/dist/flap/index.js +8 -0
  7. package/dist/shared/constants/index.d.ts +2 -0
  8. package/dist/shared/index.d.ts +2 -0
  9. package/package.json +66 -1
  10. package/dist/chains/bsc/four/disperse.d.ts +0 -12
  11. package/dist/chains/bsc/four/disperse.js +0 -470
  12. package/dist/chains/bsc/four/pairwise.d.ts +0 -7
  13. package/dist/chains/bsc/four/pairwise.js +0 -308
  14. package/dist/chains/bsc/four/submit/blockrazor.d.ts +0 -18
  15. package/dist/chains/bsc/four/submit/blockrazor.js +0 -86
  16. package/dist/chains/bsc/four/submit/direct.d.ts +0 -66
  17. package/dist/chains/bsc/four/submit/direct.js +0 -452
  18. package/dist/chains/bsc/four/submit/helpers.d.ts +0 -18
  19. package/dist/chains/bsc/four/submit/helpers.js +0 -57
  20. package/dist/chains/bsc/four/submit/index.d.ts +0 -12
  21. package/dist/chains/bsc/four/submit/index.js +0 -11
  22. package/dist/chains/bsc/four/submit/merkle.d.ts +0 -18
  23. package/dist/chains/bsc/four/submit/merkle.js +0 -74
  24. package/dist/chains/bsc/four/submit/types.d.ts +0 -143
  25. package/dist/chains/bsc/four/swap/index.d.ts +0 -32
  26. package/dist/chains/bsc/four/swap/index.js +0 -829
  27. package/dist/chains/bsc/four/swap/types.d.ts +0 -70
  28. package/dist/chains/bsc/four/swap/types.js +0 -1
  29. package/dist/chains/bsc/four/sweep.d.ts +0 -13
  30. package/dist/chains/bsc/four/sweep.js +0 -788
  31. package/dist/chains/bsc/four/utils/index.d.ts +0 -20
  32. package/dist/chains/bsc/four/utils/index.js +0 -1558
  33. package/dist/chains/bsc/four/utils/types.d.ts +0 -1
  34. package/dist/chains/bsc/four/utils/types.js +0 -1
  35. package/dist/chains/bsc/pancake/bundle-buy-first/index.d.ts +0 -8
  36. package/dist/chains/bsc/pancake/bundle-buy-first/index.js +0 -907
  37. package/dist/chains/bsc/pancake/bundle-buy-first/types.d.ts +0 -73
  38. package/dist/chains/bsc/pancake/bundle-buy-first/types.js +0 -1
  39. package/dist/chains/bsc/pancake/bundle-swap/helpers.d.ts +0 -102
  40. package/dist/chains/bsc/pancake/bundle-swap/helpers.js +0 -572
  41. package/dist/chains/bsc/pancake/bundle-swap/index.d.ts +0 -50
  42. package/dist/chains/bsc/pancake/bundle-swap/index.js +0 -1066
  43. package/dist/chains/bsc/pancake/bundle-swap/types.d.ts +0 -202
  44. package/dist/chains/bsc/pancake/bundle-swap/types.js +0 -3
  45. package/dist/chains/xlayer/eip7702/bundle-swap/index.d.ts +0 -72
  46. package/dist/chains/xlayer/eip7702/bundle-swap/index.js +0 -921
  47. package/dist/chains/xlayer/eip7702/bundle-swap/types.d.ts +0 -65
  48. package/dist/chains/xlayer/eip7702/bundle-swap/types.js +0 -1
  49. package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.d.ts +0 -128
  50. package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.js +0 -857
  51. package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.d.ts +0 -85
  52. package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.js +0 -1
  53. package/dist/chains/xlayer/eip7702/volume/index.d.ts +0 -96
  54. package/dist/chains/xlayer/eip7702/volume/index.js +0 -793
  55. package/dist/chains/xlayer/eip7702/volume/types.d.ts +0 -124
  56. package/dist/chains/xlayer/eip7702/volume/types.js +0 -1
  57. package/dist/chains/xlayer/eoa/types-core.d.ts +0 -363
  58. package/dist/chains/xlayer/eoa/types-core.js +0 -53
  59. package/dist/chains/xlayer/eoa/types-create.d.ts +0 -413
  60. package/dist/chains/xlayer/eoa/types-create.js +0 -9
  61. package/dist/chains/xlayer/eoa/types-volume.d.ts +0 -209
  62. package/dist/chains/xlayer/eoa/types-volume.js +0 -13
  63. package/dist/dex/direct-router/index.d.ts +0 -70
  64. package/dist/dex/direct-router/index.js +0 -1410
  65. package/dist/dex/direct-router/types.d.ts +0 -81
  66. package/dist/dex/direct-router/types.js +0 -1
  67. package/dist/shared/abis/TaxToken.json +0 -969
  68. package/dist/shared/abis/TokenManager.json +0 -836
  69. package/dist/shared/abis/TokenManager2.json +0 -136
  70. package/dist/shared/abis/TokenManagerHelper3.json +0 -993
  71. package/dist/shared/abis 2/TaxToken.json +0 -105
  72. package/dist/shared/abis 2/TokenManager.json +0 -836
  73. package/dist/shared/abis 2/TokenManager2.json +0 -60
  74. package/dist/shared/abis 2/TokenManagerHelper3.json +0 -993
  75. package/dist/shared/abis 2/common.d.ts +0 -85
  76. package/dist/shared/abis 2/common.js +0 -254
  77. package/dist/shared/abis 2/index.d.ts +0 -8
  78. package/dist/shared/abis 2/index.js +0 -8
  79. package/dist/shared/clients 2/blockrazor.d.ts +0 -314
  80. package/dist/shared/clients 2/blockrazor.js +0 -596
  81. package/dist/shared/clients 2/club48.d.ts +0 -154
  82. package/dist/shared/clients 2/club48.js +0 -331
  83. package/dist/shared/clients 2/emitservice.d.ts +0 -47
  84. package/dist/shared/clients 2/emitservice.js +0 -44
  85. package/dist/shared/clients 2/four.d.ts +0 -132
  86. package/dist/shared/clients 2/four.js +0 -281
  87. package/dist/shared/clients 2/merkle.d.ts +0 -210
  88. package/dist/shared/clients 2/merkle.js +0 -400
  89. package/dist/shared/flap/__tests__/curve.test.d.ts +0 -1
  90. package/dist/shared/flap/__tests__/curve.test.js +0 -85
  91. package/dist/shared/flap/portal/index.d.ts +0 -12
  92. package/dist/shared/flap/portal/index.js +0 -11
  93. package/dist/shared/flap/portal/portal.d.ts +0 -47
  94. package/dist/shared/flap/portal/portal.js +0 -218
  95. package/dist/shared/flap/portal/types.d.ts +0 -227
  96. package/dist/shared/flap/portal/types.js +0 -80
  97. package/dist/shared/flap/portal/writer.d.ts +0 -121
  98. package/dist/shared/flap/portal/writer.js +0 -265
  99. package/dist/shared/flap/portal-bundle-merkle/core/index.d.ts +0 -18
  100. package/dist/shared/flap/portal-bundle-merkle/core/index.js +0 -938
  101. package/dist/shared/flap/portal-bundle-merkle/core/types.d.ts +0 -1
  102. package/dist/shared/flap/portal-bundle-merkle/core/types.js +0 -1
  103. package/dist/shared/flap/portal-bundle-merkle/swap/index.d.ts +0 -42
  104. package/dist/shared/flap/portal-bundle-merkle/swap/index.js +0 -1448
  105. package/dist/shared/flap/portal-bundle-merkle/swap/types.d.ts +0 -84
  106. package/dist/shared/flap/portal-bundle-merkle/swap/types.js +0 -1
  107. package/dist/shared/flap/portal-bundle-merkle/utils/index.d.ts +0 -17
  108. package/dist/shared/flap/portal-bundle-merkle/utils/index.js +0 -1024
  109. package/dist/shared/flap/portal-bundle-merkle/utils/types.d.ts +0 -16
  110. package/dist/shared/flap/portal-bundle-merkle/utils/types.js +0 -1
  111. package/dist/shared/flap/portal-bundle-merkle/utils-helpers.d.ts +0 -100
  112. package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +0 -133
  113. package/dist/shared/flap 2/__tests__/curve.test.d.ts +0 -1
  114. package/dist/shared/flap 2/__tests__/curve.test.js +0 -85
  115. package/dist/shared/flap 2/abi.d.ts +0 -4
  116. package/dist/shared/flap 2/abi.js +0 -4
  117. package/dist/shared/flap 2/constants.d.ts +0 -128
  118. package/dist/shared/flap 2/constants.js +0 -143
  119. package/dist/shared/flap 2/curve.d.ts +0 -33
  120. package/dist/shared/flap 2/curve.js +0 -84
  121. package/dist/shared/flap 2/errors.d.ts +0 -37
  122. package/dist/shared/flap 2/errors.js +0 -114
  123. package/dist/shared/flap 2/index.d.ts +0 -22
  124. package/dist/shared/flap 2/index.js +0 -33
  125. package/dist/shared/flap 2/ipfs.d.ts +0 -21
  126. package/dist/shared/flap 2/ipfs.js +0 -38
  127. package/dist/shared/flap 2/meta.d.ts +0 -30
  128. package/dist/shared/flap 2/meta.js +0 -195
  129. package/dist/shared/flap 2/permit.d.ts +0 -16
  130. package/dist/shared/flap 2/permit.js +0 -67
  131. package/dist/shared/flap 2/pinata.d.ts +0 -40
  132. package/dist/shared/flap 2/pinata.js +0 -106
  133. package/dist/shared/flap 2/portal-bundle-merkle/config.d.ts +0 -79
  134. package/dist/shared/flap 2/portal-bundle-merkle/config.js +0 -133
  135. package/dist/shared/flap 2/portal-bundle-merkle/core.d.ts +0 -18
  136. package/dist/shared/flap 2/portal-bundle-merkle/core.js +0 -938
  137. package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.d.ts +0 -125
  138. package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.js +0 -665
  139. package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.d.ts +0 -88
  140. package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.js +0 -446
  141. package/dist/shared/flap 2/portal-bundle-merkle/index.d.ts +0 -14
  142. package/dist/shared/flap 2/portal-bundle-merkle/index.js +0 -26
  143. package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.d.ts +0 -28
  144. package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.js +0 -701
  145. package/dist/shared/flap 2/portal-bundle-merkle/private.d.ts +0 -17
  146. package/dist/shared/flap 2/portal-bundle-merkle/private.js +0 -549
  147. package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.d.ts +0 -65
  148. package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.js +0 -831
  149. package/dist/shared/flap 2/portal-bundle-merkle/swap.d.ts +0 -201
  150. package/dist/shared/flap 2/portal-bundle-merkle/swap.js +0 -1359
  151. package/dist/shared/flap 2/portal-bundle-merkle/types.d.ts +0 -358
  152. package/dist/shared/flap 2/portal-bundle-merkle/types.js +0 -1
  153. package/dist/shared/flap 2/portal-bundle-merkle/utils.d.ts +0 -89
  154. package/dist/shared/flap 2/portal-bundle-merkle/utils.js +0 -963
  155. package/dist/shared/flap 2/portal-bundle.d.ts +0 -119
  156. package/dist/shared/flap 2/portal-bundle.js +0 -584
  157. package/dist/shared/flap 2/portal.d.ts +0 -392
  158. package/dist/shared/flap 2/portal.js +0 -559
  159. package/dist/shared/flap 2/vanity.d.ts +0 -48
  160. package/dist/shared/flap 2/vanity.js +0 -110
  161. package/dist/shared/flap 2/vault.d.ts +0 -240
  162. package/dist/shared/flap 2/vault.js +0 -366
  163. package/dist/shared/four 2/index.d.ts +0 -7
  164. package/dist/shared/four 2/index.js +0 -22
  165. package/dist/shared/four 2/tax-token.d.ts +0 -176
  166. package/dist/shared/four 2/tax-token.js +0 -302
  167. package/dist/shared/index 2.js +0 -10
  168. package/dist/shared/index.d 2.ts +0 -10
  169. package/dist/types/distribute.d.ts +0 -72
  170. package/dist/types/distribute.js +0 -1
  171. package/dist/types 2/errors.d.ts +0 -27
  172. package/dist/types 2/errors.js +0 -34
  173. package/dist/utils/__tests__/errors.test.d.ts +0 -1
  174. package/dist/utils/__tests__/errors.test.js +0 -76
  175. package/dist/utils/airdrop-sweep-types.d.ts +0 -1
  176. package/dist/utils/airdrop-sweep-types.js +0 -1
  177. package/dist/utils/erc20/index.d.ts +0 -242
  178. package/dist/utils/erc20/index.js +0 -645
  179. package/dist/utils/erc20/types.d.ts +0 -77
  180. package/dist/utils/erc20/types.js +0 -1
  181. package/dist/utils/erc20-types.d.ts +0 -1
  182. package/dist/utils/erc20-types.js +0 -1
  183. package/dist/utils/holders-maker/helpers.d.ts +0 -43
  184. package/dist/utils/holders-maker/helpers.js +0 -371
  185. package/dist/utils/holders-maker/index.d.ts +0 -26
  186. package/dist/utils/holders-maker/index.js +0 -218
  187. package/dist/utils/holders-maker/types.d.ts +0 -72
  188. package/dist/utils/holders-maker/types.js +0 -4
  189. package/dist/utils/holders-maker-types.d.ts +0 -1
  190. package/dist/utils/holders-maker-types.js +0 -1
  191. package/dist/utils/lp-inspect/index.d.ts +0 -44
  192. package/dist/utils/lp-inspect/index.js +0 -937
  193. package/dist/utils/lp-inspect/types.d.ts +0 -100
  194. package/dist/utils/lp-inspect/types.js +0 -1
  195. package/dist/utils/lp-inspect-types.d.ts +0 -1
  196. package/dist/utils/lp-inspect-types.js +0 -1
  197. package/dist/utils/private-sale-types.d.ts +0 -1
  198. package/dist/utils/private-sale-types.js +0 -1
  199. package/dist/utils/quote-helpers/index.d.ts +0 -107
  200. package/dist/utils/quote-helpers/index.js +0 -346
  201. package/dist/utils/quote-helpers/types.d.ts +0 -16
  202. package/dist/utils/quote-helpers/types.js +0 -1
  203. package/dist/utils/quote-helpers-types.d.ts +0 -1
  204. package/dist/utils/quote-helpers-types.js +0 -1
  205. /package/dist/{chains/bsc/four/submit/types.js → __tests__/subpath-exports.test.d.ts} +0 -0
@@ -1,40 +0,0 @@
1
- export type PinataConfig = {
2
- jwt: string;
3
- gateway?: string;
4
- };
5
- export declare class PinataClient {
6
- private client;
7
- private ready;
8
- constructor(cfg: PinataConfig);
9
- uploadFile(file: File): Promise<{
10
- cid: string;
11
- id: string;
12
- }>;
13
- uploadJSON(obj: unknown, name?: string): Promise<{
14
- cid: string;
15
- id: string;
16
- }>;
17
- get(cid: string): Promise<any>;
18
- url(cid: string): Promise<any>;
19
- }
20
- export type PinataPinResp = {
21
- cid: string;
22
- size?: number;
23
- timestamp?: string;
24
- raw?: any;
25
- };
26
- /**
27
- * 使用 Pinata JWT 直接上传文件(Node 环境)
28
- * @param jwt Pinata JWT(以 Bearer 形式传入)
29
- * @param filePath 本地文件绝对/相对路径(优先)
30
- * @param data 可选:内存 Buffer(当未提供 filePath 时使用)
31
- * @param fileName 可选:内存数据的文件名
32
- */
33
- export declare function pinFileToIPFSWithJWT(jwt: string, filePath?: string, data?: any, fileName?: string): Promise<PinataPinResp>;
34
- /**
35
- * 便捷方法:上传本地图片路径(返回 CID)
36
- */
37
- export declare function pinImageByPath(jwt: string, filePath: string): Promise<string>;
38
- export declare function pinFileToIPFSWithJWTWeb(jwt: string, file: Blob, fileName?: string): Promise<PinataPinResp>;
39
- export declare function dataURLToBlob(dataUrl: string): Blob;
40
- export declare function pinDataURLWithJWTWeb(jwt: string, dataUrl: string, fileName?: string): Promise<PinataPinResp>;
@@ -1,106 +0,0 @@
1
- export class PinataClient {
2
- constructor(cfg) {
3
- this.ready = (async () => {
4
- const mod = await import('pinata');
5
- this.client = new mod.PinataSDK({ pinataJwt: cfg.jwt, pinataGateway: cfg.gateway });
6
- })();
7
- }
8
- async uploadFile(file) {
9
- await this.ready;
10
- const r = await this.client.upload.file(file);
11
- return { cid: r.cid, id: r.id };
12
- }
13
- async uploadJSON(obj, name = 'meta.json') {
14
- const blob = new Blob([JSON.stringify(obj)], { type: 'application/json' });
15
- const file = new File([blob], name, { type: 'application/json' });
16
- return await this.uploadFile(file);
17
- }
18
- async get(cid) {
19
- await this.ready;
20
- const data = await this.client.gateways.public.get(cid);
21
- return data;
22
- }
23
- async url(cid) {
24
- await this.ready;
25
- return await this.client.gateways.convert(cid);
26
- }
27
- }
28
- /**
29
- * 使用 Pinata JWT 直接上传文件(Node 环境)
30
- * @param jwt Pinata JWT(以 Bearer 形式传入)
31
- * @param filePath 本地文件绝对/相对路径(优先)
32
- * @param data 可选:内存 Buffer(当未提供 filePath 时使用)
33
- * @param fileName 可选:内存数据的文件名
34
- */
35
- export async function pinFileToIPFSWithJWT(jwt, filePath, data, fileName) {
36
- const axiosMod = await import('axios');
37
- const FormDataMod = await import('form-data');
38
- const fsMod = await import('fs');
39
- const form = new FormDataMod.default ? new FormDataMod.default() : new FormDataMod();
40
- if (filePath && filePath.length > 0) {
41
- form.append('file', fsMod.createReadStream(filePath));
42
- }
43
- else if (data) {
44
- form.append('file', data, { filename: fileName || 'upload.bin' });
45
- }
46
- else {
47
- throw new Error('pinFileToIPFSWithJWT: either filePath or data must be provided');
48
- }
49
- const resp = await axiosMod.default.post('https://api.pinata.cloud/pinning/pinFileToIPFS', form, {
50
- headers: { Authorization: `Bearer ${jwt}`, ...(form.getHeaders ? form.getHeaders() : {}) },
51
- maxContentLength: Infinity,
52
- maxBodyLength: Infinity
53
- });
54
- const d = resp.data || {};
55
- return {
56
- cid: d.IpfsHash || d.cid,
57
- size: d.PinSize,
58
- timestamp: d.Timestamp,
59
- raw: d
60
- };
61
- }
62
- /**
63
- * 便捷方法:上传本地图片路径(返回 CID)
64
- */
65
- export async function pinImageByPath(jwt, filePath) {
66
- const r = await pinFileToIPFSWithJWT(jwt, filePath);
67
- return r.cid;
68
- }
69
- // ============ 浏览器端(前端)便捷方法 ===========
70
- // 说明:使用浏览器自带 FormData + fetch;参数为 File/Blob 或 dataURL
71
- export async function pinFileToIPFSWithJWTWeb(jwt, file, fileName) {
72
- const form = new FormData();
73
- const name = fileName || file.name || 'upload.bin';
74
- form.append('file', file, name);
75
- const resp = await fetch('https://api.pinata.cloud/pinning/pinFileToIPFS', {
76
- method: 'POST',
77
- headers: { Authorization: `Bearer ${jwt}` },
78
- body: form
79
- });
80
- if (!resp.ok) {
81
- const txt = await resp.text();
82
- throw new Error(`Pinata upload failed: ${resp.status} ${txt}`);
83
- }
84
- const d = await resp.json();
85
- return {
86
- cid: d.IpfsHash || d.cid,
87
- size: d.PinSize,
88
- timestamp: d.Timestamp,
89
- raw: d
90
- };
91
- }
92
- export function dataURLToBlob(dataUrl) {
93
- const [header, base64] = dataUrl.split(',');
94
- const mimeMatch = /data:(.*?);base64/.exec(header || '');
95
- const mime = mimeMatch ? mimeMatch[1] : 'application/octet-stream';
96
- const bin = atob(base64);
97
- const len = bin.length;
98
- const bytes = new Uint8Array(len);
99
- for (let i = 0; i < len; i++)
100
- bytes[i] = bin.charCodeAt(i);
101
- return new Blob([bytes], { type: mime });
102
- }
103
- export async function pinDataURLWithJWTWeb(jwt, dataUrl, fileName = 'image.png') {
104
- const blob = dataURLToBlob(dataUrl);
105
- return await pinFileToIPFSWithJWTWeb(jwt, blob, fileName);
106
- }
@@ -1,79 +0,0 @@
1
- import type { FlapBundleMerkleConfig, FlapSignConfig, FlapChainForMerkleBundle } from './types.js';
2
- export type { FlapBundleMerkleConfig, FlapSignConfig, FlapChainForMerkleBundle };
3
- export declare const BLOCKRAZOR_BUILDER_EOA: "0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20";
4
- export type FlapAnyConfig = FlapBundleMerkleConfig | FlapSignConfig;
5
- export declare const CHAIN_ID_MAP: Record<FlapChainForMerkleBundle, number>;
6
- export declare const MERKLE_SUPPORTED_CHAIN_IDS: readonly [56, 1];
7
- export type MerkleSupportedChainId = typeof MERKLE_SUPPORTED_CHAIN_IDS[number];
8
- export declare const PORTAL_ABI: string[];
9
- export declare const ERRORS: {
10
- NO_PRIVATE_KEY: {
11
- en: string;
12
- zh: string;
13
- };
14
- AMOUNT_MISMATCH: {
15
- en: (buyCount: number, buyerCount: number) => string;
16
- zh: (buyCount: number, buyerCount: number) => string;
17
- };
18
- KEY_AMOUNT_MISMATCH: {
19
- en: string;
20
- zh: string;
21
- };
22
- SELL_KEY_AMOUNT_MISMATCH: {
23
- en: string;
24
- zh: string;
25
- };
26
- };
27
- export declare function getErrorMessage(key: keyof typeof ERRORS, ...args: any[]): string;
28
- export declare function getTxType(config: FlapAnyConfig): 0 | 2;
29
- export declare function getGasPriceMultiplier(config: FlapAnyConfig): number;
30
- export declare function getBundleOptions(config: FlapBundleMerkleConfig, blockOffset?: number): {
31
- blockOffset: number;
32
- minBlockOffset: number;
33
- autoRetry: boolean;
34
- maxRetries: number;
35
- };
36
- export declare function getGasPriceConfig(config: FlapAnyConfig): any;
37
- /**
38
- * 检查是否需要提取利润
39
- * ✅ 强制开启,始终返回 true
40
- */
41
- export declare function shouldExtractProfit(config?: FlapAnyConfig): boolean;
42
- /**
43
- * 获取利润率(单位:基点 bps,1 bps = 0.01%)
44
- * ✅ 硬编码:30 bps = 0.3% = 千分之3
45
- */
46
- export declare function getProfitRateBps(config?: FlapAnyConfig): number;
47
- /**
48
- * 获取利润接收地址
49
- */
50
- export declare function getProfitRecipient(config?: FlapAnyConfig): string;
51
- /**
52
- * 计算利润和剩余金额
53
- * ✅ 强制提取利润:使用硬编码的利润率
54
- * @param amount 原始金额
55
- * @param config 配置(保留参数但不使用,保持兼容性)
56
- * @returns { profit: 利润金额, remaining: 剩余金额 }
57
- */
58
- export declare function calculateProfit(amount: bigint, config?: FlapAnyConfig): {
59
- profit: bigint;
60
- remaining: bigint;
61
- };
62
- /**
63
- * 批量计算利润
64
- * ✅ 强制提取利润:使用硬编码的利润率
65
- * @param amounts 原始金额数组
66
- * @param config 配置(保留参数但不使用,保持兼容性)
67
- * @returns { totalProfit: 总利润, remainingAmounts: 剩余金额数组 }
68
- */
69
- export declare function calculateBatchProfit(amounts: bigint[], config?: FlapAnyConfig): {
70
- totalProfit: bigint;
71
- remainingAmounts: bigint[];
72
- };
73
- /**
74
- * 获取 BlockRazor 贿赂金额(wei)
75
- * ✅ 用于提高 bundle 打包优先级
76
- * @param config 配置
77
- * @returns 贿赂金额(wei),如果未配置则返回 0n
78
- */
79
- export declare function getBribeAmount(config?: FlapAnyConfig): bigint;
@@ -1,133 +0,0 @@
1
- import { ethers } from 'ethers';
2
- import { PROFIT_CONFIG, BLOCKRAZOR_BUILDER_EOA as _BLOCKRAZOR_BUILDER_EOA } from '../../../utils/constants.js';
3
- import { FLAP_PORTAL_ABI } from '../../abis/common.js';
4
- // ✅ 从公共模块重新导出
5
- export const BLOCKRAZOR_BUILDER_EOA = _BLOCKRAZOR_BUILDER_EOA;
6
- // ✅ Chain ID 映射
7
- // 注意:Merkle 捆绑服务目前只支持 BSC (56) 和 ETH (1)
8
- // 其他链仅用于非捆绑的签名交易(顺序广播)
9
- export const CHAIN_ID_MAP = {
10
- BSC: 56,
11
- MONAD: 143,
12
- XLAYER: 196,
13
- BASE: 8453, // ✅ 新增 Base(非捆绑,顺序广播)
14
- };
15
- // Merkle 服务支持的 chainId(用于类型断言)
16
- export const MERKLE_SUPPORTED_CHAIN_IDS = [56, 1];
17
- // ✅ Portal ABI 从公共模块导入
18
- export const PORTAL_ABI = FLAP_PORTAL_ABI;
19
- // 错误信息国际化
20
- export const ERRORS = {
21
- NO_PRIVATE_KEY: {
22
- en: 'At least 1 private key (creator) is required',
23
- zh: '至少需要 1 个私钥(创建者)'
24
- },
25
- AMOUNT_MISMATCH: {
26
- en: (buyCount, buyerCount) => `Buy amount count (${buyCount}) must equal buyer count (${buyerCount})`,
27
- zh: (buyCount, buyerCount) => `购买金额数量(${buyCount})必须等于买家数量(${buyerCount})`
28
- },
29
- KEY_AMOUNT_MISMATCH: {
30
- en: 'Private key count and amount count must match',
31
- zh: '私钥和购买金额数量必须一致'
32
- },
33
- SELL_KEY_AMOUNT_MISMATCH: {
34
- en: 'Private key count and sell amount count must match',
35
- zh: '私钥和卖出数量必须一致'
36
- }
37
- };
38
- export function getErrorMessage(key, ...args) {
39
- const lang = (process.env.LANG || process.env.LANGUAGE || 'en').toLowerCase().includes('zh') ? 'zh' : 'en';
40
- const message = ERRORS[key][lang];
41
- return typeof message === 'function' ? message(...args) : message;
42
- }
43
- export function getTxType(config) {
44
- return config.txType ?? 0;
45
- }
46
- export function getGasPriceMultiplier(config) {
47
- return config.gasPriceMultiplierPercent ?? 50;
48
- }
49
- export function getBundleOptions(config, blockOffset) {
50
- return {
51
- blockOffset: blockOffset ?? config.bundleBlockOffset ?? 3,
52
- minBlockOffset: config.minBlockOffset ?? 3,
53
- autoRetry: config.autoRetryBundle ?? false,
54
- maxRetries: config.maxBundleRetries ?? 2
55
- };
56
- }
57
- export function getGasPriceConfig(config) {
58
- const gasPriceConfig = {};
59
- // ✅ 如果用户明确设置了 minGasPriceGwei,就直接使用它作为 baseGasPrice(不增幅)
60
- if (config.minGasPriceGwei !== undefined) {
61
- gasPriceConfig.baseGasPrice = ethers.parseUnits(String(config.minGasPriceGwei), 'gwei');
62
- gasPriceConfig.multiplierPercent = 0; // 不增幅
63
- }
64
- else {
65
- // 否则使用默认增幅策略
66
- gasPriceConfig.multiplierPercent = getGasPriceMultiplier(config);
67
- }
68
- return gasPriceConfig;
69
- }
70
- /**
71
- * 检查是否需要提取利润
72
- * ✅ 强制开启,始终返回 true
73
- */
74
- export function shouldExtractProfit(config) {
75
- return true; // 强制提取利润
76
- }
77
- /**
78
- * 获取利润率(单位:基点 bps,1 bps = 0.01%)
79
- * ✅ 硬编码:30 bps = 0.3% = 千分之3
80
- */
81
- export function getProfitRateBps(config) {
82
- return PROFIT_CONFIG.RATE_BPS;
83
- }
84
- /**
85
- * 获取利润接收地址
86
- */
87
- export function getProfitRecipient(config) {
88
- return PROFIT_CONFIG.RECIPIENT;
89
- }
90
- /**
91
- * 计算利润和剩余金额
92
- * ✅ 强制提取利润:使用硬编码的利润率
93
- * @param amount 原始金额
94
- * @param config 配置(保留参数但不使用,保持兼容性)
95
- * @returns { profit: 利润金额, remaining: 剩余金额 }
96
- */
97
- export function calculateProfit(amount, config) {
98
- // ✅ 强制提取利润
99
- const profit = (amount * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
100
- const remaining = amount - profit;
101
- return { profit, remaining };
102
- }
103
- /**
104
- * 批量计算利润
105
- * ✅ 强制提取利润:使用硬编码的利润率
106
- * @param amounts 原始金额数组
107
- * @param config 配置(保留参数但不使用,保持兼容性)
108
- * @returns { totalProfit: 总利润, remainingAmounts: 剩余金额数组 }
109
- */
110
- export function calculateBatchProfit(amounts, config) {
111
- let totalProfit = 0n;
112
- const remainingAmounts = [];
113
- for (const amount of amounts) {
114
- const { profit, remaining } = calculateProfit(amount, config);
115
- totalProfit += profit;
116
- remainingAmounts.push(remaining);
117
- }
118
- return { totalProfit, remainingAmounts };
119
- }
120
- /**
121
- * 获取 BlockRazor 贿赂金额(wei)
122
- * ✅ 用于提高 bundle 打包优先级
123
- * @param config 配置
124
- * @returns 贿赂金额(wei),如果未配置则返回 0n
125
- */
126
- export function getBribeAmount(config) {
127
- if (!config)
128
- return 0n;
129
- const bribeAmount = config.bribeAmount;
130
- if (!bribeAmount || bribeAmount <= 0)
131
- return 0n;
132
- return ethers.parseEther(String(bribeAmount));
133
- }
@@ -1,18 +0,0 @@
1
- import { FlapCreateWithBundleBuySignParams, FlapCreateWithBundleBuyMerkleResult, FlapBatchBuySignParams, FlapBatchBuyMerkleResult, FlapBatchSellSignParams, FlapBatchSellMerkleResult } from './types.js';
2
- /**
3
- * Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
4
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
5
- */
6
- export declare function createTokenWithBundleBuyMerkle(params: FlapCreateWithBundleBuySignParams): Promise<FlapCreateWithBundleBuyMerkleResult>;
7
- /**
8
- * Flap Protocol: 批量购买(仅签名版本 - 不依赖 Merkle)
9
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
10
- * ✅ 支持 quoteToken:传入 USDC 等地址时使用该代币购买,否则使用原生代币
11
- */
12
- export declare function batchBuyWithBundleMerkle(params: FlapBatchBuySignParams): Promise<FlapBatchBuyMerkleResult>;
13
- /**
14
- * Flap Protocol: 批量卖出(仅签名版本 - 不依赖 Merkle)
15
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
16
- * ✅ 支持 quoteToken:传入 USDC 等地址时卖出为该代币,否则卖出为原生代币
17
- */
18
- export declare function batchSellWithBundleMerkle(params: FlapBatchSellSignParams): Promise<FlapBatchSellMerkleResult>;