four-flap-meme-sdk 2.2.14 → 2.2.15
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/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { TM2, type FourChainV2 } from './contracts/tm2.js';
|
|
|
15
15
|
export { Helper3, Helper3Writer } from './contracts/helper3.js';
|
|
16
16
|
export { CDPV2 } from './shared/flap/curve.js';
|
|
17
17
|
export { FlapPortal, FlapPortalWriter, type FlapChain, type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId } from './shared/flap/portal.js';
|
|
18
|
-
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, FLAP_INFINITY_HOOKS_BSC, type GraduatedDexMetrics, type InfinityPoolKey, } from './shared/flap/graduated-dex.js';
|
|
18
|
+
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, PCS_INFINITY_VAULT_BSC, FLAP_INFINITY_HOOKS_BSC, type GraduatedDexMetrics, type InfinityPoolKey, } from './shared/flap/graduated-dex.js';
|
|
19
19
|
export { uploadTokenMeta, type TokenMetaInput } from './shared/flap/ipfs.js';
|
|
20
20
|
export { buildPermitPiggybackAuto } from './shared/flap/permit.js';
|
|
21
21
|
export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './shared/flap/vanity.js';
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export { TM2 } from './contracts/tm2.js';
|
|
|
48
48
|
export { Helper3, Helper3Writer } from './contracts/helper3.js';
|
|
49
49
|
export { CDPV2 } from './shared/flap/curve.js';
|
|
50
50
|
export { FlapPortal, FlapPortalWriter, validateTaxDistribution, TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId } from './shared/flap/portal.js';
|
|
51
|
-
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, FLAP_INFINITY_HOOKS_BSC, } from './shared/flap/graduated-dex.js';
|
|
51
|
+
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, PCS_INFINITY_VAULT_BSC, FLAP_INFINITY_HOOKS_BSC, } from './shared/flap/graduated-dex.js';
|
|
52
52
|
export { uploadTokenMeta } from './shared/flap/ipfs.js';
|
|
53
53
|
export { buildPermitPiggybackAuto } from './shared/flap/permit.js';
|
|
54
54
|
export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './shared/flap/vanity.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, FLAP_INFINITY_HOOKS_BSC, type GraduatedDexMetrics, type InfinityPoolKey, } from '../../utils/pcs-infinity-cl.js';
|
|
1
|
+
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, PCS_INFINITY_VAULT_BSC, FLAP_INFINITY_HOOKS_BSC, type GraduatedDexMetrics, type InfinityPoolKey, } from '../../utils/pcs-infinity-cl.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, FLAP_INFINITY_HOOKS_BSC, } from '../../utils/pcs-infinity-cl.js';
|
|
1
|
+
export { getFlapGraduatedDexMetrics, buildFlapInfinityPoolKey, computeInfinityPoolId, isInfinityCLPoolManagerAddress, isFlapInfinityCLGraduated, resolvePortalQuoteInputToken, PCS_INFINITY_CL_POOL_MANAGER_BSC, PCS_INFINITY_VAULT_BSC, FLAP_INFINITY_HOOKS_BSC, } from '../../utils/pcs-infinity-cl.js';
|
|
@@ -2,6 +2,8 @@ import type { FlapPortal } from '../shared/flap/portal.js';
|
|
|
2
2
|
import type { TokenStateV7 } from '../shared/flap/portal.js';
|
|
3
3
|
/** PancakeSwap Infinity CL PoolManager(BSC / Base 同址) */
|
|
4
4
|
export declare const PCS_INFINITY_CL_POOL_MANAGER_BSC = "0xa0FfB9c1CE1Fe56963B0321B32E7A0302114058b";
|
|
5
|
+
/** PancakeSwap Infinity Vault(全池代币记账;BSC / Base 同址) */
|
|
6
|
+
export declare const PCS_INFINITY_VAULT_BSC = "0x238a358808379702088667322f80aC48bAd5e6c4";
|
|
5
7
|
/** Flap Portal 毕业到 Infinity CL 时使用的 hooks(BSC) */
|
|
6
8
|
export declare const FLAP_INFINITY_HOOKS_BSC = "0xF1A9aA042454b8553bE3896597ff11a0f011c1c1";
|
|
7
9
|
export type InfinityPoolKey = {
|
|
@@ -3,6 +3,8 @@ import { ZERO_ADDRESS } from '../shared/flap/constants.js';
|
|
|
3
3
|
import { ERC20_ABI } from '../shared/abis/common.js';
|
|
4
4
|
/** PancakeSwap Infinity CL PoolManager(BSC / Base 同址) */
|
|
5
5
|
export const PCS_INFINITY_CL_POOL_MANAGER_BSC = '0xa0FfB9c1CE1Fe56963B0321B32E7A0302114058b';
|
|
6
|
+
/** PancakeSwap Infinity Vault(全池代币记账;BSC / Base 同址) */
|
|
7
|
+
export const PCS_INFINITY_VAULT_BSC = '0x238a358808379702088667322f80aC48bAd5e6c4';
|
|
6
8
|
/** Flap Portal 毕业到 Infinity CL 时使用的 hooks(BSC) */
|
|
7
9
|
export const FLAP_INFINITY_HOOKS_BSC = '0xF1A9aA042454b8553bE3896597ff11a0f011c1c1';
|
|
8
10
|
const CL_POOL_MANAGER_ABI = [
|
|
@@ -120,8 +122,8 @@ function v3SpotPriceQuotePerToken(params) {
|
|
|
120
122
|
quoteTokenAddress: params.quoteTokenAddress,
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
|
-
/** Infinity CL:用 quote 估算当前可卖出的 WBNB 深度(贴近 GMGN
|
|
124
|
-
async function
|
|
125
|
+
/** Infinity CL:用 quote 估算当前可卖出的 WBNB 深度(贴近 GMGN,勿把探测代币量当池子持仓) */
|
|
126
|
+
async function estimateInfinityPoolQuoteBnbDepth(portal, tokenAddress) {
|
|
125
127
|
const inputQuote = ZERO_ADDRESS;
|
|
126
128
|
const probeTokens = [110000000n, 100000000n, 50000000n, 10000000n].map((m) => m * 10n ** 18n);
|
|
127
129
|
for (const amt of probeTokens) {
|
|
@@ -131,18 +133,32 @@ async function estimateInfinityPoolQuoteDepth(portal, tokenAddress, wrappedNativ
|
|
|
131
133
|
outputToken: inputQuote,
|
|
132
134
|
inputAmount: amt,
|
|
133
135
|
});
|
|
134
|
-
if (bnbOut > 0n)
|
|
135
|
-
return
|
|
136
|
-
poolBNBAmount: formatEther(bnbOut),
|
|
137
|
-
poolTokenAmount: formatEther(amt),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
136
|
+
if (bnbOut > 0n)
|
|
137
|
+
return formatEther(bnbOut);
|
|
140
138
|
}
|
|
141
139
|
catch {
|
|
142
140
|
/* try smaller */
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
|
-
return
|
|
143
|
+
return '0';
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Infinity CL 池内代币量:读 Vault 中该 token 余额(与 GMGN 池子代币列一致)
|
|
147
|
+
* 注意:Vault 为全协议记账层,对 Flap 毕业主池通常即该交易对持仓。
|
|
148
|
+
*/
|
|
149
|
+
async function getInfinityCLPoolTokenReserve(params) {
|
|
150
|
+
const chain = String(params.chain || '').toUpperCase();
|
|
151
|
+
const vault = chain === 'BSC' || chain === 'BASE' ? PCS_INFINITY_VAULT_BSC : '';
|
|
152
|
+
if (!vault)
|
|
153
|
+
return '0';
|
|
154
|
+
try {
|
|
155
|
+
const provider = new JsonRpcProvider(params.rpcUrl);
|
|
156
|
+
const bal = (await new Contract(params.tokenAddress, ERC20_ABI, provider).balanceOf(vault));
|
|
157
|
+
return formatEther(bal);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return '0';
|
|
161
|
+
}
|
|
146
162
|
}
|
|
147
163
|
async function quotePortalPrice(portal, tokenAddress, quoteTokenAddress, wrappedNativeAddress) {
|
|
148
164
|
try {
|
|
@@ -263,11 +279,18 @@ async function getInfinityCLGraduatedMetrics(params) {
|
|
|
263
279
|
/* keep portal quote */
|
|
264
280
|
}
|
|
265
281
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
282
|
+
const [bnbDepth, tokenReserve] = await Promise.all([
|
|
283
|
+
estimateInfinityPoolQuoteBnbDepth(params.portal, params.tokenAddress),
|
|
284
|
+
getInfinityCLPoolTokenReserve({
|
|
285
|
+
tokenAddress: params.tokenAddress,
|
|
286
|
+
rpcUrl: params.rpcUrl,
|
|
287
|
+
chain: params.chain,
|
|
288
|
+
}),
|
|
289
|
+
]);
|
|
290
|
+
if (parseFloat(bnbDepth) > 0)
|
|
291
|
+
poolBNBAmount = bnbDepth;
|
|
292
|
+
if (parseFloat(tokenReserve) > 0)
|
|
293
|
+
poolTokenAmount = tokenReserve;
|
|
271
294
|
if (!price)
|
|
272
295
|
price = '0';
|
|
273
296
|
return {
|