Getting Exchange Rate
import { stakePoolInfo } from "@ignitionfi/fogo-stake-pool"
import { Connection, PublicKey } from "@solana/web3.js"
const poolAddress = "ign1zuR3YsvLVsEu8WzsyazBA8EVWUxPPHKnhqhoSTB"
const rpcUrl = "https://mainnet.fogo.io/"
async function getPoolInfo() {
const connection = new Connection(rpcUrl)
const poolInfo = await stakePoolInfo(connection, new PublicKey(poolAddress))
const poolData = {
poolMint: poolInfo.poolMint,
totalPoolTokens: poolInfo.poolTokenSupply,
totalFogo: poolInfo.totalLamports,
reserveStakeLamports: poolInfo.details.reserveStakeLamports,
// iFOGO price (iFOGO / FOGO):
rate:
Number(poolInfo.poolTokenSupply) > 0
? Number(poolInfo.totalLamports) / Number(poolInfo.poolTokenSupply)
: 1,
}
console.log(poolData)
return poolData
}Last updated
