four-flap-meme-sdk 1.2.43 → 1.2.44
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.
|
@@ -80,15 +80,6 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
80
80
|
sellAmountWei,
|
|
81
81
|
skipBalanceCheck: sameAddress
|
|
82
82
|
});
|
|
83
|
-
const approvalTx = await buildApprovalTransaction({
|
|
84
|
-
tokenAddress,
|
|
85
|
-
provider: chainContext.provider,
|
|
86
|
-
seller,
|
|
87
|
-
decimals: sellerInfo.decimals,
|
|
88
|
-
portalAddress: chainContext.portalAddress,
|
|
89
|
-
chainId: chainContext.chainId,
|
|
90
|
-
config
|
|
91
|
-
});
|
|
92
83
|
const portalBuyer = new Contract(chainContext.portalAddress, PORTAL_ABI, buyer);
|
|
93
84
|
const portalSeller = new Contract(chainContext.portalAddress, PORTAL_ABI, seller);
|
|
94
85
|
const buyUnsigned = await portalBuyer.swapExactInput.populateTransaction({
|
|
@@ -110,6 +101,19 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
110
101
|
const gasPrice = await getOptimizedGasPrice(chainContext.provider, getGasPriceConfig(config));
|
|
111
102
|
const txType = getTxType(config);
|
|
112
103
|
const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
|
|
104
|
+
const nonceManager = new NonceManager(chainContext.provider);
|
|
105
|
+
const approvalTx = await buildApprovalTransaction({
|
|
106
|
+
tokenAddress,
|
|
107
|
+
provider: chainContext.provider,
|
|
108
|
+
seller,
|
|
109
|
+
decimals: sellerInfo.decimals,
|
|
110
|
+
portalAddress: chainContext.portalAddress,
|
|
111
|
+
chainId: chainContext.chainId,
|
|
112
|
+
config,
|
|
113
|
+
nonceManager,
|
|
114
|
+
gasPrice,
|
|
115
|
+
txType
|
|
116
|
+
});
|
|
113
117
|
const profitAmount = calculateProfitAmount(estimatedSellFunds);
|
|
114
118
|
await validateNativeBalances({
|
|
115
119
|
sameAddress,
|
|
@@ -122,7 +126,6 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
122
126
|
provider: chainContext.provider,
|
|
123
127
|
nativeToken: chainContext.nativeToken
|
|
124
128
|
});
|
|
125
|
-
const nonceManager = new NonceManager(chainContext.provider);
|
|
126
129
|
const noncePlan = await planNonces({
|
|
127
130
|
buyer,
|
|
128
131
|
seller,
|
|
@@ -243,17 +246,14 @@ async function ensureSellerBalance({ tokenAddress, provider, seller, sellAmountW
|
|
|
243
246
|
}
|
|
244
247
|
return { decimals };
|
|
245
248
|
}
|
|
246
|
-
async function buildApprovalTransaction({ tokenAddress, provider, seller, decimals, portalAddress, chainId, config }) {
|
|
249
|
+
async function buildApprovalTransaction({ tokenAddress, provider, seller, decimals, portalAddress, chainId, config, nonceManager, gasPrice, txType }) {
|
|
247
250
|
const allowanceContract = new Contract(tokenAddress, ERC20_ALLOWANCE_ABI, provider);
|
|
248
251
|
const currentAllowance = await allowanceContract.allowance(seller.address, portalAddress);
|
|
249
252
|
const approvalThreshold = ethers.parseUnits('1000000000', decimals);
|
|
250
253
|
if (currentAllowance >= approvalThreshold) {
|
|
251
254
|
return null;
|
|
252
255
|
}
|
|
253
|
-
const nonceManager = new NonceManager(provider);
|
|
254
256
|
const approvalNonce = await nonceManager.getNextNonce(seller);
|
|
255
|
-
const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
|
|
256
|
-
const txType = getTxType(config);
|
|
257
257
|
return await seller.signTransaction({
|
|
258
258
|
to: tokenAddress,
|
|
259
259
|
data: APPROVE_INTERFACE.encodeFunctionData('approve', [portalAddress, ethers.MaxUint256]),
|
|
@@ -73,14 +73,6 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
73
73
|
provider: context.provider
|
|
74
74
|
});
|
|
75
75
|
const decimals = await getTokenDecimals(context.provider, tokenAddress);
|
|
76
|
-
const approvalTx = await ensureSellerApproval({
|
|
77
|
-
tokenAddress,
|
|
78
|
-
seller,
|
|
79
|
-
provider: context.provider,
|
|
80
|
-
decimals,
|
|
81
|
-
chainId: context.chainId,
|
|
82
|
-
config
|
|
83
|
-
});
|
|
84
76
|
const swapUnsigned = await buildRouteTransactions({
|
|
85
77
|
routeParams,
|
|
86
78
|
buyerFundsWei: buyerFundsInfo.buyerFundsWei,
|
|
@@ -103,12 +95,23 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
103
95
|
const finalGasLimit = getGasLimit(config);
|
|
104
96
|
const gasPrice = await getGasPrice(context.provider, config);
|
|
105
97
|
const txType = config.txType ?? 0;
|
|
98
|
+
const nonceManager = new NonceManager(context.provider);
|
|
99
|
+
const approvalTx = await ensureSellerApproval({
|
|
100
|
+
tokenAddress,
|
|
101
|
+
seller,
|
|
102
|
+
provider: context.provider,
|
|
103
|
+
decimals,
|
|
104
|
+
chainId: context.chainId,
|
|
105
|
+
config,
|
|
106
|
+
nonceManager,
|
|
107
|
+
gasPrice,
|
|
108
|
+
txType
|
|
109
|
+
});
|
|
106
110
|
const profitAmount = await estimateProfitAmount({
|
|
107
111
|
provider: context.provider,
|
|
108
112
|
tokenAddress,
|
|
109
113
|
sellAmountToken: quoteResult.quotedTokenOut
|
|
110
114
|
});
|
|
111
|
-
const nonceManager = new NonceManager(context.provider);
|
|
112
115
|
const noncePlan = await planNonces({
|
|
113
116
|
buyer,
|
|
114
117
|
seller,
|
|
@@ -265,7 +268,7 @@ function calculateBuyerNeed({ quotedNative, buyerBalance, reserveGas, slippageBp
|
|
|
265
268
|
: buyerBalance - reserveGas;
|
|
266
269
|
return { buyerNeedTotal, maxBuyerValue };
|
|
267
270
|
}
|
|
268
|
-
async function ensureSellerApproval({ tokenAddress, seller, provider, decimals, chainId, config }) {
|
|
271
|
+
async function ensureSellerApproval({ tokenAddress, seller, provider, decimals, chainId, config, nonceManager, gasPrice, txType }) {
|
|
269
272
|
if (config.skipApprovalCheck) {
|
|
270
273
|
return null;
|
|
271
274
|
}
|
|
@@ -275,10 +278,7 @@ async function ensureSellerApproval({ tokenAddress, seller, provider, decimals,
|
|
|
275
278
|
if (currentAllowance >= threshold) {
|
|
276
279
|
return null;
|
|
277
280
|
}
|
|
278
|
-
const nonceManager = new NonceManager(provider);
|
|
279
281
|
const approvalNonce = await nonceManager.getNextNonce(seller);
|
|
280
|
-
const gasPrice = await getGasPrice(provider, config);
|
|
281
|
-
const txType = config.txType ?? 0;
|
|
282
282
|
return await seller.signTransaction({
|
|
283
283
|
to: tokenAddress,
|
|
284
284
|
data: APPROVE_INTERFACE.encodeFunctionData('approve', [PANCAKE_PROXY_ADDRESS, ethers.MaxUint256]),
|