parseAbi、Web3.js 或 Web3.py 集成中使用。
Factory
创建官方 LFG.RICH 代币,并把它们注册到 Hook。
Uniswap V4 Hook
处理定价、地板价、储备、费用、抵押品、借贷和 hook callbacks。
Swap Router
为用户和集成提供简单的买入和卖出函数。
Token
由 Factory 创建的 ERC20-compatible 代币合约。
Pool Manager
Hook 和 Router 流程使用的 Uniswap V4 Pool Manager。
Referral 与 Treasury
处理邀请绑定、推荐奖励路由和平台侧会计。
请使用本页展示的 V5 签名。旧示例中调用
createToken(name, symbol, totalFeeBps)、estimateBuy(poolId, ethIn) 或 estimateSell(poolId, tokenAmount) 的方式已经过时。BNB Smart Chain V5 地址
| 合约 | 地址 |
|---|---|
| Factory | 0x429a7ef0129649a97bb3f1e961dd56d9bd4ac01f |
| Uniswap V4 Hook | 0xc18e6e1926113cdcf53f3ec1a89d3eb84cc6a888 |
| Swap Router | 0x4018abd5d24ee48c642e7e518a8aef03b59ec150 |
| Referral / Invite | 0x162e11887f6788ac9625a980e68044bee7f9d746 |
| Treasury | 0xdb5b8aa5cecf7a6fe1812fb2ccc37723076b19d9 |
| Pool Manager | 0x28e2Ea090877bF75740558f6BFB36A5ffeE9e9dF |
网络常量
| 值 | 含义 |
|---|---|
| Chain ID | 56 |
| 原生货币 | BNB |
| 池手续费 | 3000 |
| Tick spacing | 60 |
PoolKey 中的原生货币地址 | 0x0000000000000000000000000000000000000000 |
| ABI 版本 | v5 |
重要的 V5 交互规则
在 LFG.RICH 创建的每个代币都有自己的poolId 和自己的 Uniswap V4 PoolKey。
为了保证集成稳定可靠:
1
加载代币
从公共 API 或 Factory 创建的代币数据开始。
2
解析 poolId
使用
token.pool_id、token.poolId,或 hook.tokenToPoolId(tokenAddress)。3
解析或构建 PoolKey
可用时优先使用
factory.getPoolKey(tokenAddress)。4
通过 Hook 获取报价
V5 买卖估算需要
poolId 和钱包地址。5
通过 Swap Router 执行交易
买入和卖出调用使用该代币对应的 PoolKey。
6
通过 Hook 执行借贷
Borrow、borrow more、repay 和价格读取都使用
poolId。API 的 token 对象通常包含
pool_id。可以直接使用该值,但外部工具仍然应该知道如何通过 hook.tokenToPoolId(tokenAddress) 或 factory.getTokenInfo(tokenAddress).poolId 解析同一个值。Factory ABI
Factory 用于创建官方 LFG.RICH 代币、保存代币元数据、保存创建者所有权,并公开每个代币的PoolKey 数据。
export const FACTORY_V5_ABI = [
"function owner() view returns (address)",
"function poolManager() view returns (address)",
"function hook() view returns (address)",
"function creationFee() view returns (uint256)",
"function POOL_FEE() view returns (uint24)",
"function TICK_SPACING() view returns (int24)",
"function INIT_SQRT_PRICE() view returns (uint160)",
"function allTokens(uint256) view returns (address)",
"function tokenToCreator(address) view returns (address)",
"function tokenInfoMap(address) view returns (address tokenAddress, uint256 tokenId, address creator, string name, string symbol, bytes32 poolId)",
"function setInviteContract(address _invite)",
"function setInviteRewardsEnabled(bool _enabled)",
"function createToken(string name, string symbol, uint256 devBuyEth) payable returns (address token, bytes32 poolId)",
"function setCreationFee(uint256 newFee)",
"function transferOwnership(address newOwner)",
"function withdrawAll(address to)",
"function updateCreator(address token, address newCreator)",
"function totalTokens() view returns (uint256)",
"function isOfficialToken(address token) view returns (bool)",
"function getTokenInfo(address token) view returns (tuple(address tokenAddress, uint256 tokenId, address creator, string name, string symbol, bytes32 poolId))",
"function getUserTokens(address user) view returns (address[])",
"function getPoolKey(address token) view returns (tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks))",
"event TokenCreated(address indexed token, uint256 indexed tokenId, address indexed creator, string name, string symbol, bytes32 poolId)",
"event DevBuy(address indexed token, address indexed creator, uint256 ethAmount, bytes32 poolId)",
"event CreationFeeUpdated(uint256 oldFee, uint256 newFee)",
"event Withdrawn(address indexed to, uint256 amount)",
"event CreatorUpdated(address indexed token, address indexed oldCreator, address indexed newCreator)",
"event InviteContractUpdated(address indexed inviteContract)",
"event InviteRewardsToggled(bool enabled)"
] as const;
Factory 说明
createToken(name, symbol, devBuyEth) 会创建代币,并可选地执行一次创建者初始买入。交易的 value 必须覆盖 creationFee + devBuyEth。代币描述、Logo、网站、X/Twitter、Telegram、QQ 群和其他元数据,会在代币创建后通过公开应用 API 保存。
Uniswap V4 Hook ABI
Hook 包含 LFG.RICH 协议逻辑,包括代币状态、价格估算、手续费、地板价支持、借款、追加借款、还款和事件。export const HOOK_V5_ABI = [
"function BPS_DENOMINATOR() view returns (uint256)",
"function TOTAL_FEE_BPS() view returns (uint256)",
"function PLATFORM_FEE_BPS() view returns (uint256)",
"function INVITER_FEE_BPS() view returns (uint256)",
"function BORROW_FEE_BPS() view returns (uint256)",
"function BORROW_PLATFORM_FEE_BPS() view returns (uint256)",
"function BORROW_PARENT_FEE_BPS() view returns (uint256)",
"function COLLATERAL_RATIO_BPS() view returns (uint256)",
"function DUST_THRESHOLD() view returns (uint256)",
"function MIN_SWEEP_AMOUNT() view returns (uint256)",
"function DEFAULT_AUTO_FLOOR_PCT_BPS() view returns (uint256)",
"function POOL_FEE() view returns (uint24)",
"function POOL_MANAGER() view returns (address)",
"function TREASURY() view returns (address)",
"function FACTORY() view returns (address)",
"function K() view returns (uint256)",
"function inviteContract() view returns (address)",
"function inviteRewardsEnabled() view returns (bool)",
"function tokenStates(bytes32) view returns (address token, address creator, uint256 floorPrice, uint256 realETH, uint256 virtualETH, uint256 totalBorrowedETH, uint256 collateralSupply, uint256 allTimeHighPrice, uint256 k, uint256 autoFloorPctBps, bool initialized)",
"function tokenToPoolId(address) view returns (bytes32)",
"function borrowedETH(bytes32, address) view returns (uint256)",
"function collateralBalance(bytes32, address) view returns (uint256)",
"function totalPurchasedETH(address) view returns (uint256)",
"function effectiveETH(bytes32 poolId) view returns (uint256)",
"function getEffectivePrice(bytes32 poolId) view returns (uint256)",
"function circulatingSupply(bytes32 poolId) view returns (uint256)",
"function maxFloorPrice(bytes32 poolId) view returns (uint256)",
"function getTokenK(bytes32 poolId) view returns (uint256)",
"function getAutoFloorPct(bytes32 poolId) view returns (uint256)",
"function estimateBuy(bytes32 poolId, uint256 ethIn, address buyer) view returns (uint256 tokensOut, uint256 platformFee, uint256 inviterFee)",
"function estimateSell(bytes32 poolId, uint256 tokenAmount, address seller) view returns (uint256 ethOut, uint256 platformFee, uint256 inviterFee)",
"function estimateBorrowMore(bytes32 poolId, address user) view returns (uint256 additionalEth, uint256 fee)",
"function getHookPermissions() pure returns (tuple(bool beforeInitialize, bool afterInitialize, bool beforeAddLiquidity, bool afterAddLiquidity, bool beforeRemoveLiquidity, bool afterRemoveLiquidity, bool beforeSwap, bool afterSwap, bool beforeDonate, bool afterDonate, bool beforeSwapReturnDelta, bool afterSwapReturnDelta, bool afterAddLiquidityReturnDelta, bool afterRemoveLiquidityReturnDelta))",
"function registerToken(address token, bytes32 poolId, address creator)",
"function updateCreator(bytes32 poolId, address newCreator)",
"function setInviteContract(address _invite)",
"function setInviteRewardsEnabled(bool _enabled)",
"function borrow(bytes32 poolId, uint256 amount)",
"function borrowMore(bytes32 poolId)",
"function repay(bytes32 poolId) payable",
"function devMint(bytes32 poolId, address dev) payable",
"function beforeInitialize(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160) returns (bytes4)",
"function afterInitialize(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), uint160, int24) pure returns (bytes4)",
"function beforeAddLiquidity(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), tuple(int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt), bytes) returns (bytes4)",
"function afterAddLiquidity(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), tuple(int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt), int256, int256, bytes) pure returns (bytes4, int256)",
"function beforeRemoveLiquidity(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), tuple(int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt), bytes) pure returns (bytes4)",
"function afterRemoveLiquidity(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), tuple(int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt), int256, int256, bytes) pure returns (bytes4, int256)",
"function beforeSwap(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, tuple(bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96) params, bytes hookData) returns (bytes4 selector, int256 delta, uint24 lpFeeOverride)",
"function afterSwap(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), tuple(bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96), int256, bytes) pure returns (bytes4, int128)",
"function beforeDonate(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), uint256, uint256, bytes) pure returns (bytes4)",
"function afterDonate(address, tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks), uint256, uint256, bytes) pure returns (bytes4)",
"event TokenRegistered(address indexed token, bytes32 indexed poolId, address creator)",
"event Buy(bytes32 indexed poolId, address indexed buyer, uint256 ethIn, uint256 tokensOut, uint256 newPrice)",
"event Sell(bytes32 indexed poolId, address indexed seller, uint256 tokensIn, uint256 ethOut, uint256 newPrice)",
"event FloorRaised(bytes32 indexed poolId, uint256 oldFloor, uint256 newFloor)",
"event ATHUpdated(bytes32 indexed poolId, uint256 oldATH, uint256 newATH)",
"event KUpdated(bytes32 indexed poolId, uint256 oldK, uint256 newK)",
"event Borrow(bytes32 indexed poolId, address indexed user, uint256 tokensLocked, uint256 ethBorrowed, uint256 fee)",
"event BorrowMore(bytes32 indexed poolId, address indexed user, uint256 additionalEth, uint256 fee)",
"event Repay(bytes32 indexed poolId, address indexed user, uint256 ethRepaid, uint256 tokensUnlocked)",
"event Sweep(bytes32 indexed poolId, uint256 amount)",
"event DustCollected(bytes32 indexed poolId, uint256 amount)",
"event CreatorUpdated(bytes32 indexed poolId, address indexed oldCreator, address indexed newCreator)",
"event InviteContractUpdated(address indexed oldInvite, address indexed newInvite)",
"event InviteRewardsToggled(bool enabled)"
] as const;
Hook 说明
estimateBuy 和 estimateSell 需要传入用户地址,因为邀请关系可能会改变手续费分配。如果钱包未连接,只能在纯展示报价时使用零地址。真实交易工具应该在钱包连接后重新估算。
V5 的 tokenStates(poolId) 返回 floorPrice、realETH、virtualETH、totalBorrowedETH、collateralSupply、allTimeHighPrice、k 和 autoFloorPctBps。旧字段,例如 floorBoostPool 或 totalReserveAccumulated,不是 V5 Hook 状态的一部分。
Swap Router ABI
Swap Router 是用户执行买入和卖出的入口合约。export const SWAP_ROUTER_V5_ABI = [
"function poolManager() view returns (address)",
"function buy(tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint256 minTokensOut) payable",
"function sell(tuple(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint256 tokenAmount, uint256 minEthOut)",
"function unlockCallback(bytes data) returns (bytes)"
] as const;
Token ABI
Factory 创建的每个代币都是 ERC-20 代币,并由 Hook 控制协议层面的铸造和销毁操作。export const TOKEN_V5_ABI = [
"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 transfer(address to, uint256 amount) returns (bool)",
"function approve(address spender, uint256 amount) returns (bool)",
"function transferFrom(address from, address to, uint256 amount) returns (bool)",
"function allowance(address owner, address spender) view returns (uint256)",
"function increaseAllowance(address spender, uint256 addedValue) returns (bool)",
"function decreaseAllowance(address spender, uint256 subtractedValue) returns (bool)",
"function FACTORY() view returns (address)",
"function hook() view returns (address)",
"function hookLocked() view returns (bool)",
"function setHook(address _hook)",
"function mint(address to, uint256 amount)",
"function burn(address from, uint256 amount)",
"event Transfer(address indexed from, address indexed to, uint256 value)",
"event Approval(address indexed owner, address indexed spender, uint256 value)"
] as const;
Referral ABI
Referral 合约保存 V5 手续费系统使用的邀请关系。export const REFERRAL_V5_ABI = [
"function owner() view returns (address)",
"function isWhitelist(address) view returns (bool)",
"function initialInviter(address) view returns (address)",
"function parent(address) view returns (address)",
"function inviteCount(address) view returns (uint256)",
"function isBound(address) view returns (bool)",
"function transferOwnership(address newOwner)",
"function setWhitelist(address[] addrs, bool status)",
"function bind(address inviter)",
"function getInfo(address user) view returns (address _initialInviter, address _parent, uint256 _inviteCount, bool _isBound)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event WhitelistUpdated(address indexed addr, bool status)",
"event Bound(address indexed user, address indexed inviter, address indexed initialInv)"
] as const;
Treasury ABI
Treasury 接收协议资金,并可将资金 flush 到配置的接收地址。export const TREASURY_ABI = [
"function owner() view returns (address)",
"function recipient() view returns (address)",
"function setRecipient(address _recipient)",
"function flush()"
] as const;
推荐的公开配置接口
不想硬编码地址和 ABI 的集成,可以读取公开配置接口:const res = await fetch('https://lfg.rich/api/bsc/tokens/config/contracts');
const json = await res.json();
console.log(json.data.factoryAddress);
console.log(json.data.hookAddress);
console.log(json.data.swapRouterAddress);
console.log(json.data.factoryABI);
console.log(json.data.hookABI);
/jsonconfig/contracts。
