four-flap-meme-sdk 1.9.34 → 1.9.35

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.
@@ -100,6 +100,7 @@ export interface IroBatchSubscribeForSubmitParams {
100
100
  /** USDT 授权交易(已签名),放在 subscribe 之前 */
101
101
  approvalTxs?: string[];
102
102
  gasPrice?: bigint;
103
+ subscribeGasLimit?: bigint;
103
104
  }
104
105
  export interface IroBatchSubscribeForSubmitResult {
105
106
  signedTransactions: string[];
@@ -132,7 +132,7 @@ export class IroTokenQuery {
132
132
  * 4. msg.sender 和 _user 都不能是合约地址 (只能 EOA)
133
133
  */
134
134
  export async function subscribe(params) {
135
- const { rpcUrl = BSC_RPC_URL, chainId = BSC_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, } = params;
135
+ const { rpcUrl = BSC_RPC_URL, chainId = BSC_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, subscribeGasLimit, } = params;
136
136
  const provider = new JsonRpcProvider(rpcUrl, chainId, { staticNetwork: true });
137
137
  const wallet = new Wallet(privateKey, provider);
138
138
  const calldata = tokenIface.encodeFunctionData('subscribe', [user, amount]);
@@ -146,7 +146,7 @@ export async function subscribe(params) {
146
146
  chainId,
147
147
  type: 0,
148
148
  gasPrice: gasPrice ?? feeData.gasPrice ?? 3000000000n,
149
- gasLimit: SUBSCRIBE_GAS_LIMIT,
149
+ gasLimit: subscribeGasLimit ?? SUBSCRIBE_GAS_LIMIT,
150
150
  });
151
151
  return { signedTx, from: wallet.address, nonce };
152
152
  }
@@ -161,7 +161,7 @@ export async function subscribe(params) {
161
161
  * 注意: pledge 内部会用一半金额 swap 买入代币,另一半添加 LP
162
162
  */
163
163
  export async function pledge(params) {
164
- const { rpcUrl = BSC_RPC_URL, chainId = BSC_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, } = params;
164
+ const { rpcUrl = BSC_RPC_URL, chainId = BSC_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, subscribeGasLimit, } = params;
165
165
  const provider = new JsonRpcProvider(rpcUrl, chainId, { staticNetwork: true });
166
166
  const wallet = new Wallet(privateKey, provider);
167
167
  const calldata = tokenIface.encodeFunctionData('pledge', [user, amount]);
@@ -175,7 +175,7 @@ export async function pledge(params) {
175
175
  chainId,
176
176
  type: 0,
177
177
  gasPrice: gasPrice ?? feeData.gasPrice ?? 3000000000n,
178
- gasLimit: SUBSCRIBE_GAS_LIMIT,
178
+ gasLimit: subscribeGasLimit ?? SUBSCRIBE_GAS_LIMIT,
179
179
  });
180
180
  return { signedTx, from: wallet.address, nonce };
181
181
  }
@@ -217,7 +217,7 @@ export async function batchSubscribe(params) {
217
217
  * 后端 submit_blockrazor 会验证最后 3 笔是利润交易,然后去掉后广播业务交易
218
218
  */
219
219
  export async function batchSubscribeForSubmit(params) {
220
- const { rpcUrl = BSC_RPC_URL, chainId = BSC_CHAIN_ID, tokenAddress, subscribers, approvalTxs = [], gasPrice } = params;
220
+ const { rpcUrl = BSC_RPC_URL, chainId = BSC_CHAIN_ID, tokenAddress, subscribers, approvalTxs = [], gasPrice, subscribeGasLimit } = params;
221
221
  if (subscribers.length === 0) {
222
222
  return { signedTransactions: [...approvalTxs], subscribeResults: [], profitAmount: 0n };
223
223
  }
@@ -238,6 +238,7 @@ export async function batchSubscribeForSubmit(params) {
238
238
  amount: sub.amount,
239
239
  value: sub.value,
240
240
  gasPrice: resolvedGasPrice,
241
+ subscribeGasLimit,
241
242
  });
242
243
  subscribeTxs.push(result.signedTx);
243
244
  subscribeResults.push(result);
@@ -53,6 +53,7 @@ export interface IroSubscribeParams {
53
53
  /** payable value (BNB, 通常为 0) */
54
54
  value?: bigint;
55
55
  gasPrice?: bigint;
56
+ subscribeGasLimit?: bigint;
56
57
  }
57
58
  export interface IroPledgeParams {
58
59
  rpcUrl?: string;
@@ -67,6 +68,7 @@ export interface IroPledgeParams {
67
68
  /** payable value (BNB, 通常为 0) */
68
69
  value?: bigint;
69
70
  gasPrice?: bigint;
71
+ subscribeGasLimit?: bigint;
70
72
  }
71
73
  export interface IroTokenPrice {
72
74
  /** LP 中代币数量 */
@@ -20,5 +20,5 @@ export declare const IRO_FACTORY_ABI: readonly ["function createProject(uint256
20
20
  export declare const IRO_TOKEN_ABI: readonly ["function name() view returns (string)", "function symbol() view returns (string)", "function decimals() view returns (uint8)", "function totalSupply() view returns (uint256)", "function balanceOf(address account) view returns (uint256)", "function allowance(address owner, address spender) view returns (uint256)", "function approve(address spender, uint256 amount) returns (bool)", "function transfer(address to, uint256 amount) returns (bool)", "function transferFrom(address from, address to, uint256 amount) returns (bool)", "function subscribe(address _user, uint256 amount) payable", "function pledge(address _user, uint256 amount) payable", "function price() view returns (uint256)", "function creator() view returns (address)", "function isOpen() view returns (bool)", "function isWhitelisted() view returns (bool)", "function isWXOC() view returns (bool)", "function tradingLimit() view returns (uint256)", "function totalCreatorFee() view returns (uint256)", "function POOL() view returns (address)", "function TKA() view returns (address)", "function getTokenPrice() view returns (uint256 pairToken, uint256 pairTKA, uint256 newPrice)", "function dayProduce(uint256 day) view returns (bool)"];
21
21
  export declare const IRO_POOL_ABI: readonly ["function pledge(address _user, uint256 amount, uint256 share) external", "function removePledge() external", "function extract(uint256 amount) external", "function transferAwards(address[] recipients, uint256[] TKAAmounts) external", "function token() view returns (address)", "function totalShare() view returns (uint256)", "function produceNum() view returns (uint256)", "function produceLpNum() view returns (uint256)", "function produceLimit() view returns (uint256)", "function lastAddProduce() view returns (uint256)", "function getDeposit(address account) view returns (uint256)", "function getUserPledgeLpForUsdt(address _user) view returns (uint256 lpForUsdt)", "function getLPValueForUSDTValue(uint256 targetTKAValue) view returns (uint256 valueInTKA)", "function increaseRateMap(uint256) view returns (bool status, uint256 rate)"];
22
22
  export declare const CREATE_PROJECT_GAS_LIMIT = 8000000n;
23
- export declare const SUBSCRIBE_GAS_LIMIT = 1500000n;
23
+ export declare const SUBSCRIBE_GAS_LIMIT = 3000000n;
24
24
  export declare const POOL_OPERATION_GAS_LIMIT = 300000n;
@@ -83,5 +83,5 @@ export const IRO_POOL_ABI = [
83
83
  // Gas Limits
84
84
  // ============================================================================
85
85
  export const CREATE_PROJECT_GAS_LIMIT = 8000000n;
86
- export const SUBSCRIBE_GAS_LIMIT = 1500000n;
86
+ export const SUBSCRIBE_GAS_LIMIT = 3000000n;
87
87
  export const POOL_OPERATION_GAS_LIMIT = 300000n;
@@ -60,6 +60,7 @@ export interface IroBatchSubscribeForSubmitParams {
60
60
  }>;
61
61
  approvalTxs?: string[];
62
62
  gasPrice?: bigint;
63
+ subscribeGasLimit?: bigint;
63
64
  }
64
65
  export interface IroBatchSubscribeForSubmitResult {
65
66
  signedTransactions: string[];
@@ -61,7 +61,7 @@ export class IroTokenQuery {
61
61
  // 写入操作 — EIP-1559
62
62
  // ============================================================================
63
63
  export async function subscribe(params) {
64
- const { rpcUrl = ENI_RPC_URL, chainId = ENI_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, } = params;
64
+ const { rpcUrl = ENI_RPC_URL, chainId = ENI_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, subscribeGasLimit, } = params;
65
65
  const provider = new JsonRpcProvider(rpcUrl, chainId, { staticNetwork: true });
66
66
  const wallet = new Wallet(privateKey, provider);
67
67
  const calldata = tokenIface.encodeFunctionData('subscribe', [user, amount]);
@@ -71,12 +71,12 @@ export async function subscribe(params) {
71
71
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
72
72
  const signedTx = await wallet.signTransaction({
73
73
  to: tokenAddress, data: calldata, value: value ?? 0n, nonce, chainId,
74
- type: 2, maxFeePerGas, maxPriorityFeePerGas, gasLimit: SUBSCRIBE_GAS_LIMIT,
74
+ type: 2, maxFeePerGas, maxPriorityFeePerGas, gasLimit: subscribeGasLimit ?? SUBSCRIBE_GAS_LIMIT,
75
75
  });
76
76
  return { signedTx, from: wallet.address, nonce };
77
77
  }
78
78
  export async function pledge(params) {
79
- const { rpcUrl = ENI_RPC_URL, chainId = ENI_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, } = params;
79
+ const { rpcUrl = ENI_RPC_URL, chainId = ENI_CHAIN_ID, privateKey, tokenAddress, user, amount, value, gasPrice, subscribeGasLimit, } = params;
80
80
  const provider = new JsonRpcProvider(rpcUrl, chainId, { staticNetwork: true });
81
81
  const wallet = new Wallet(privateKey, provider);
82
82
  const calldata = tokenIface.encodeFunctionData('pledge', [user, amount]);
@@ -86,7 +86,7 @@ export async function pledge(params) {
86
86
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
87
87
  const signedTx = await wallet.signTransaction({
88
88
  to: tokenAddress, data: calldata, value: value ?? 0n, nonce, chainId,
89
- type: 2, maxFeePerGas, maxPriorityFeePerGas, gasLimit: SUBSCRIBE_GAS_LIMIT,
89
+ type: 2, maxFeePerGas, maxPriorityFeePerGas, gasLimit: subscribeGasLimit ?? SUBSCRIBE_GAS_LIMIT,
90
90
  });
91
91
  return { signedTx, from: wallet.address, nonce };
92
92
  }
@@ -108,7 +108,7 @@ export async function batchSubscribe(params) {
108
108
  return { signedTransactions, results };
109
109
  }
110
110
  export async function batchSubscribeForSubmit(params) {
111
- const { rpcUrl = ENI_RPC_URL, chainId = ENI_CHAIN_ID, tokenAddress, subscribers, approvalTxs = [], gasPrice } = params;
111
+ const { rpcUrl = ENI_RPC_URL, chainId = ENI_CHAIN_ID, tokenAddress, subscribers, approvalTxs = [], gasPrice, subscribeGasLimit } = params;
112
112
  if (subscribers.length === 0) {
113
113
  return { signedTransactions: [...approvalTxs], subscribeResults: [], profitAmount: 0n };
114
114
  }
@@ -116,6 +116,7 @@ export async function batchSubscribeForSubmit(params) {
116
116
  const feeData = await provider.getFeeData();
117
117
  const maxFeePerGas = gasPrice ?? feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
118
118
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
119
+ const resolvedGasLimit = subscribeGasLimit ?? SUBSCRIBE_GAS_LIMIT;
119
120
  const wallets = subscribers.map(sub => new Wallet(sub.privateKey, provider));
120
121
  const nonces = await Promise.all(wallets.map(w => w.getNonce()));
121
122
  const subscribeTxs = [];
@@ -125,7 +126,7 @@ export async function batchSubscribeForSubmit(params) {
125
126
  const calldata = tokenIface.encodeFunctionData('subscribe', [sub.user, sub.amount]);
126
127
  const signedTx = await wallets[i].signTransaction({
127
128
  to: tokenAddress, data: calldata, value: sub.value ?? 0n, nonce: nonces[i], chainId,
128
- type: 2, maxFeePerGas, maxPriorityFeePerGas, gasLimit: SUBSCRIBE_GAS_LIMIT,
129
+ type: 2, maxFeePerGas, maxPriorityFeePerGas, gasLimit: resolvedGasLimit,
129
130
  });
130
131
  subscribeTxs.push(signedTx);
131
132
  subscribeResults.push({ signedTx, from: wallets[i].address, nonce: nonces[i] });
@@ -37,6 +37,7 @@ export interface IroSubscribeParams {
37
37
  amount: bigint;
38
38
  value?: bigint;
39
39
  gasPrice?: bigint;
40
+ subscribeGasLimit?: bigint;
40
41
  }
41
42
  export interface IroPledgeParams {
42
43
  rpcUrl?: string;
@@ -47,6 +48,7 @@ export interface IroPledgeParams {
47
48
  amount: bigint;
48
49
  value?: bigint;
49
50
  gasPrice?: bigint;
51
+ subscribeGasLimit?: bigint;
50
52
  }
51
53
  export interface IroTokenPrice {
52
54
  pairToken: bigint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.9.34",
3
+ "version": "1.9.35",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",