Members
(constant) LAMPORTS_PER_SOL
Important Notes on Delegation and Rewards:
Activation Epoch: The epoch when a delegation is activated.
Reward Beginning Epoch: Rewards start accruing one epoch after the Activation Epoch.
Withdrawal Implications: Upon withdrawal, the 'postBalance' will be less than the balance from the previous reward.
- Source
(constant) connectDB
Establishes a connection to the MongoDB using the provided configurations. Connection configurations are sourced from environment variables.
- Source
(constant) createDelegateTransaction
Create and persist a delegate transaction
- Source
(constant) cronHandles
Initialize and run essential services.
(constant) fetchLatestEpoch
Fetch the current epoch number from the Solana network.
(constant) fetchSolanaPriceAtDate
Fetch the Solana price at a specific date.
(constant) findAPRValue
Calculates and returns the APR value for a given delegator ID based on the rewards from the last month until the latestEpoch.
- Source
(constant) findDelegators
Fetches and returns active delegators for a given validator.
- Source
(constant) getAccountInfo
Get information about a specific account.
(constant) getBlockTime
Fetch the block time of a given effective slot.
(constant) getInflationReward
Fetch the inflation rewards of delegators for a specific epoch.
(constant) getProgramAccounts
Get the accounts associated with a given program.
(constant) getSignaturesForAddress
Fetch transaction signatures related to an address.
(constant) getTransaction
Fetch details of a transaction by its signature.
(constant) populateBody
Helper function to create a JSON-RPC request body.
- Source
(constant) populateSolUsd
Populate the solUsd field in all Reward model instances
- Source
(constant) setTimestampFormat
Sets the timestamp format to UTC 00:00:00.
- Source
Methods
convertSolUsd(amount, solUsd) → {Object}
Calculates the USD value of the post balance, reward, and staked amount.
Name | Type | Description |
---|---|---|
amount | number | Amount to be converted to USD. |
solUsd | number | Current value of 1 SOL in USD. |
- Source
- An object containing the USD values of the post balance, reward, and staked amount.
- Type:
- Object
(async) delegatorCron()
Scheduled job to manage delegators.
(async) delegatorJob()
Job to create new delegators and update already populated ones.
(async) findRewards(delegatorId, epoch) → {Promise.<{reward: number, postBalance: number}>}
Fetches the inflation reward for a given delegatorId and epoch.
Name | Type | Description |
---|---|---|
delegatorId | string | The public key of the delegator. |
epoch | number | The epoch number. |
- Source
The reward and post balance.
- Type:
- Promise.<{reward: number, postBalance: number}>
(async) findStakeInfo(pubkey) → {Promise.<({pubkey: string, activationEpoch: number, deactivationEpoch: number, stake: number}|undefined)>}
Fetches stake information for a given public key.
Name | Type | Description |
---|---|---|
pubkey | string | The public key to fetch stake info for. |
- Source
The stake information or undefined if not found.
- Type:
- Promise.<({pubkey: string, activationEpoch: number, deactivationEpoch: number, stake: number}|undefined)>
(async) initializeRewardData(pubkey, delegatorReward, stakedAmount, solUsd) → {Object}
Initializes reward data for a delegator based on the reward amount and staked SOL.
Name | Type | Description |
---|---|---|
pubkey | number | The public key of the delegator. |
delegatorReward | RewardOfDelegation | The reward object containing the reward amount. |
stakedAmount | number | The amount staked in lamports. |
solUsd | number | Current value of 1 SOL in USD. |
- Source
- An object containing initialized reward data, including total days, total reward, and pending rewards in both SOL and USD.
- Type:
- Object
isRewardValidForEpoch(delegatorReward, epoch, activationEpoch, deactivationEpoch) → {boolean}
Checks if the reward is valid for the specified epoch based on activation and deactivation epochs.
Name | Type | Description |
---|---|---|
delegatorReward | RewardOfDelegation | | The reward object containing information about the delegator's reward. |
epoch | number | The current epoch number being evaluated. |
activationEpoch | number | The epoch number when the delegator's stake was activated. |
deactivationEpoch | number | The epoch number when the delegator's stake was deactivated. |
- Source
- Returns true if the reward is valid for the specified epoch, otherwise false.
- Type:
- boolean
(async) processDelegator()
Process individual delegator.
(async) processReward(rewards, epoch) → {Promise.<void>}
Processes reward information and stores it in the database.
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rewards | Object | The reward object containing information about rewards. Properties
| |||||||||||||||
epoch | number | The epoch number being processed. |
- Source
A promise that resolves once the reward has been processed.
- Type:
- Promise.<void>
(async) processUnstaking()
Handle unstaking based on epoch conditions.
(async) rewardsCron() → {Object}
Initializes the function for rewards cron job.
- Source
- A schedule job to run every day at 1am.
- Type:
- Object
(async) rewardsJob()
Job to populate rewards from the start epoch to the latest epoch for all delegators
- Source
(async) sleep(milliseconds) → {Promise.<void>}
Makes a delay for a given amount of time.
Name | Type | Description |
---|---|---|
milliseconds | number | Time to delay in milliseconds. |
- Source
- Type:
- Promise.<void>
(async) validatorRewardsCron() → {Object}
Initializes the function for rewards cron job.
- Source
- A schedule job to run every day at 1am.
- Type:
- Object
(async) validatorRewardsJob()
Job to populate validator rewards from the start epoch to the latest epoch
- Source