@ignitionfi/fogo-stake-pool 1.0.0 → 1.0.2
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/constants.d.ts +1 -1
- package/dist/index.browser.cjs.js +40 -17
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.browser.esm.js +40 -17
- package/dist/index.browser.esm.js.map +1 -1
- package/dist/index.cjs.js +40 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +40 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +40 -17
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/package.json +9 -9
- package/src/constants.ts +2 -2
- package/src/layouts.ts +2 -0
- package/src/utils/stake.ts +50 -21
package/dist/index.iife.js
CHANGED
|
@@ -19013,7 +19013,7 @@ var solanaStakePool = (function (exports, node_buffer) {
|
|
|
19013
19013
|
// Public key that identifies the SPL Stake Pool program.
|
|
19014
19014
|
const STAKE_POOL_PROGRAM_ID = new PublicKey('SP1s4uFeTAX9jsXXmwyDs1gxYYf7cdDZ8qHUHVxE1yr');
|
|
19015
19015
|
// Public key that identifies the SPL Stake Pool program deployed to devnet.
|
|
19016
|
-
const DEVNET_STAKE_POOL_PROGRAM_ID =
|
|
19016
|
+
const DEVNET_STAKE_POOL_PROGRAM_ID = STAKE_POOL_PROGRAM_ID;
|
|
19017
19017
|
// Maximum number of validators to update during UpdateValidatorListBalance.
|
|
19018
19018
|
const MAX_VALIDATORS_TO_UPDATE = 4;
|
|
19019
19019
|
// Seed for ephemeral stake account
|
|
@@ -19024,7 +19024,7 @@ var solanaStakePool = (function (exports, node_buffer) {
|
|
|
19024
19024
|
const USER_STAKE_SEED_PREFIX = node_buffer.Buffer.from('user_stake');
|
|
19025
19025
|
// Minimum amount of staked SOL required in a validator stake account to allow
|
|
19026
19026
|
// for merges without a mismatch on credits observed
|
|
19027
|
-
const MINIMUM_ACTIVE_STAKE =
|
|
19027
|
+
const MINIMUM_ACTIVE_STAKE = 1000000;
|
|
19028
19028
|
|
|
19029
19029
|
/**
|
|
19030
19030
|
* Populate a buffer of instruction data using an InstructionType
|
|
@@ -22018,40 +22018,63 @@ var solanaStakePool = (function (exports, node_buffer) {
|
|
|
22018
22018
|
}
|
|
22019
22019
|
const minBalanceForRentExemption = await connection.getMinimumBalanceForRentExemption(StakeProgram.space);
|
|
22020
22020
|
const minBalance = new BN(minBalanceForRentExemption + MINIMUM_ACTIVE_STAKE);
|
|
22021
|
-
|
|
22022
|
-
|
|
22021
|
+
// First, collect all stake account addresses we need to check
|
|
22022
|
+
const accountsToFetch = [];
|
|
22023
22023
|
for (const validator of validatorList.validators) {
|
|
22024
22024
|
if (validator.status !== ValidatorStakeInfoStatus.Active) {
|
|
22025
22025
|
continue;
|
|
22026
22026
|
}
|
|
22027
22027
|
const stakeAccountAddress = await findStakeProgramAddress(stakePoolProgramId, validator.voteAccountAddress, stakePoolAddress);
|
|
22028
|
-
|
|
22029
|
-
//
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
const isPreferred = (_a = stakePool === null || stakePool === void 0 ? void 0 : stakePool.preferredWithdrawValidatorVoteAddress) === null || _a === void 0 ? void 0 : _a.equals(validator.voteAccountAddress);
|
|
22033
|
-
accounts.push({
|
|
22028
|
+
const isPreferred = (_a = stakePool === null || stakePool === void 0 ? void 0 : stakePool.preferredWithdrawValidatorVoteAddress) === null || _a === void 0 ? void 0 : _a.equals(validator.voteAccountAddress);
|
|
22029
|
+
// Add active stake account if validator list indicates it has stake
|
|
22030
|
+
if (validator.activeStakeLamports.gt(new BN(0))) {
|
|
22031
|
+
accountsToFetch.push({
|
|
22034
22032
|
type: isPreferred ? 'preferred' : 'active',
|
|
22035
22033
|
voteAddress: validator.voteAccountAddress,
|
|
22036
22034
|
stakeAddress: stakeAccountAddress,
|
|
22037
|
-
lamports: availableActiveLamports,
|
|
22038
22035
|
});
|
|
22039
22036
|
}
|
|
22040
|
-
|
|
22041
|
-
if (transientStakeLamports.gt(new BN(0))) {
|
|
22037
|
+
// Add transient stake account if validator list indicates it has stake
|
|
22038
|
+
if (validator.transientStakeLamports.gt(new BN(0))) {
|
|
22042
22039
|
const transientStakeAccountAddress = await findTransientStakeProgramAddress(stakePoolProgramId, validator.voteAccountAddress, stakePoolAddress, validator.transientSeedSuffixStart);
|
|
22043
|
-
|
|
22040
|
+
accountsToFetch.push({
|
|
22044
22041
|
type: 'transient',
|
|
22045
22042
|
voteAddress: validator.voteAccountAddress,
|
|
22046
22043
|
stakeAddress: transientStakeAccountAddress,
|
|
22047
|
-
|
|
22044
|
+
});
|
|
22045
|
+
}
|
|
22046
|
+
}
|
|
22047
|
+
// Fetch all stake accounts + reserve in one batch call
|
|
22048
|
+
const addressesToFetch = [
|
|
22049
|
+
...accountsToFetch.map(a => a.stakeAddress),
|
|
22050
|
+
stakePool.reserveStake,
|
|
22051
|
+
];
|
|
22052
|
+
const accountInfos = await connection.getMultipleAccountsInfo(addressesToFetch);
|
|
22053
|
+
// Build accounts list using actual on-chain balances
|
|
22054
|
+
let accounts = [];
|
|
22055
|
+
for (let i = 0; i < accountsToFetch.length; i++) {
|
|
22056
|
+
const { type, voteAddress, stakeAddress } = accountsToFetch[i];
|
|
22057
|
+
const accountInfo = accountInfos[i];
|
|
22058
|
+
if (!accountInfo) {
|
|
22059
|
+
continue;
|
|
22060
|
+
}
|
|
22061
|
+
// Use actual on-chain balance instead of validator list value
|
|
22062
|
+
const actualLamports = new BN(accountInfo.lamports);
|
|
22063
|
+
const availableLamports = actualLamports.sub(minBalance);
|
|
22064
|
+
if (availableLamports.gt(new BN(0))) {
|
|
22065
|
+
accounts.push({
|
|
22066
|
+
type,
|
|
22067
|
+
voteAddress,
|
|
22068
|
+
stakeAddress,
|
|
22069
|
+
lamports: availableLamports,
|
|
22048
22070
|
});
|
|
22049
22071
|
}
|
|
22050
22072
|
}
|
|
22051
22073
|
// Sort from highest to lowest balance
|
|
22052
22074
|
accounts = accounts.sort(compareFn || ((a, b) => b.lamports.sub(a.lamports).toNumber()));
|
|
22053
|
-
|
|
22054
|
-
const
|
|
22075
|
+
// Add reserve stake using actual balance (last item in batch fetch)
|
|
22076
|
+
const reserveAccountInfo = accountInfos[accountInfos.length - 1];
|
|
22077
|
+
const reserveStakeBalance = new BN(((_b = reserveAccountInfo === null || reserveAccountInfo === void 0 ? void 0 : reserveAccountInfo.lamports) !== null && _b !== void 0 ? _b : 0) - minBalanceForRentExemption);
|
|
22055
22078
|
if (reserveStakeBalance.gt(new BN(0))) {
|
|
22056
22079
|
accounts.push({
|
|
22057
22080
|
type: 'reserve',
|