LP 交互
创建 LP 交易
添加流动性 / 铸造 sFLP
const addLiquidityAndStake = async () => {
const usdcInputAmount = new BN(1_000_000); // $1
// 这可以是池中可用的任何其他代币,例如 SOL、BTC 和 ETH
const usdcCustody = POOL_CONFIG.custodies.find(c => c.symbol === 'USDC')!;
const slippageBps: number = 800 // 0.8%
let instructions: TransactionInstruction[] = []
let additionalSigners: Signer[] = []
await flashClient.loadAddressLookupTable(POOL_CONFIG)
// flash-sdk 版本 >= 2.31.6
const { amount: minLpAmountOut, fee } = await flashClient.getAddLiquidityAmountAndFeeView(usdcInputAmount, POOL_CONFIG.poolAddress, usdcCustody.custodyAccount, POOL_CONFIG);
const minLpAmountOutAfterSlippage = minLpAmountOut
.mul(new BN(10 ** BPS_DECIMALS - slippageBps))
.div(new BN(10 ** BPS_DECIMALS))
const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 400_000 }) // addLiquidity
const addLiquidityAndStakeData = await flashClient.addLiquidityAndStake('USDC', usdcInputAmount, minLpAmountOutAfterSlippage, POOL_CONFIG);
instructions.push(...addLiquidityAndStakeData.instructions)
additionalSigners.push(...addLiquidityAndStakeData.additionalSigners)
const flpStakeAccountPK = PublicKey.findProgramAddressSync(
[Buffer.from('stake'), flashClient.provider.publicKey.toBuffer(), POOL_CONFIG.poolAddress.toBuffer()],
POOL_CONFIG.programId
)[0]
const refreshStakeInstruction = await flashClient.refreshStake('USDC', POOL_CONFIG, [flpStakeAccountPK])
instructions.push(refreshStakeInstruction)
const trxId = await flashClient.sendTransaction([setCULimitIx, ...instructions])
console.log('addLiquidityAndStake trx :>> ', trxId);
}添加复投流动性 / 铸造 FLP
移除流动性 / 销毁 sFLP
移除复投流动性 / 销毁 FLP
获取 FLP/sFLP 代币价格
1.) 使用 SDK(高级集成)
2.) 使用 API(快速简便)
✅ 响应格式(示例)
字段
描述
🔎 如何使用
获取代币价格:
最后更新于
这有帮助吗?

