calcPoolTokensForDeposit static method
Calculate the pool tokens that should be minted for a deposit of stakeLamports
Implementation
static BigInt calcPoolTokensForDeposit(
StakePoolAccount stakePoolAccount, BigInt stakeLamports) {
if (stakePoolAccount.poolTokenSupply == BigInt.zero ||
stakePoolAccount.totalLamports == BigInt.zero) {
return stakeLamports;
}
final numerator = stakeLamports * stakePoolAccount.poolTokenSupply;
if (numerator == BigInt.zero) return BigInt.zero;
return BigRational(numerator, stakePoolAccount.totalLamports).toBigInt();
}