four-flap-meme-sdk 2.2.16 → 2.2.17
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/utils/pcs-infinity-cl.js +14 -16
- package/package.json +1 -1
|
@@ -133,30 +133,28 @@ function getCachedRpcProvider(rpcUrl) {
|
|
|
133
133
|
}
|
|
134
134
|
return p;
|
|
135
135
|
}
|
|
136
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Infinity CL 池子 WBNB:取多档卖出 quote 的最大值(贴近 GMGN「池内 WBNB」)
|
|
138
|
+
* 说明:不是 Vault 总 WBNB(全协议),也不是 L*sqrtP 虚拟储备(会高估到 ~5.8)。
|
|
139
|
+
*/
|
|
137
140
|
async function estimateInfinityPoolQuoteBnbDepth(portal, tokenAddress) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
outputToken: ZERO_ADDRESS,
|
|
142
|
-
inputAmount: 110000000n * 10n ** 18n,
|
|
143
|
-
});
|
|
144
|
-
if (bnbOut > 0n)
|
|
145
|
-
return formatEther(bnbOut);
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
141
|
+
const probes = [107000000n, 105000000n, 100000000n, 90000000n].map((m) => m * 10n ** 18n);
|
|
142
|
+
let best = 0n;
|
|
143
|
+
for (const amt of probes) {
|
|
148
144
|
try {
|
|
149
145
|
const bnbOut = await portal.quoteExactInput({
|
|
150
146
|
inputToken: tokenAddress,
|
|
151
147
|
outputToken: ZERO_ADDRESS,
|
|
152
|
-
inputAmount:
|
|
148
|
+
inputAmount: amt,
|
|
153
149
|
});
|
|
154
|
-
if (bnbOut >
|
|
155
|
-
|
|
150
|
+
if (bnbOut > best)
|
|
151
|
+
best = bnbOut;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
/* 超过可成交上限会 revert,继续试更小档位 */
|
|
156
155
|
}
|
|
157
|
-
catch { /* ignore */ }
|
|
158
156
|
}
|
|
159
|
-
return '0';
|
|
157
|
+
return best > 0n ? formatEther(best) : '0';
|
|
160
158
|
}
|
|
161
159
|
/**
|
|
162
160
|
* Infinity CL 池内代币量:读 Vault 中该 token 余额(与 GMGN 池子代币列一致)
|