@hubbleprotocol/farms-sdk
Version:
237 lines (236 loc) • 8.7 kB
TypeScript
import { PublicKey, Connection } from "@solana/web3.js";
import BN from "bn.js";
import * as types from "../types";
export interface FarmStateFields {
farmAdmin: PublicKey;
globalConfig: PublicKey;
token: types.TokenInfoFields;
rewardInfos: Array<types.RewardInfoFields>;
numRewardTokens: BN;
/** Data used to calculate the rewards of the user */
numUsers: BN;
/**
* The number of token in the `farm_vault` staked (getting rewards and fees)
* Set such as `farm_vault.amount = total_staked_amount + total_pending_amount`
*/
totalStakedAmount: BN;
farmVault: PublicKey;
farmVaultsAuthority: PublicKey;
farmVaultsAuthorityBump: BN;
/**
* Only used for delegate farms
* Set to `default()` otherwise
*/
delegateAuthority: PublicKey;
/**
* Raw representation of a `TimeUnit`
* Seconds = 0, Slots = 1
*/
timeUnit: number;
/**
* Automatically set to true in case of a full authority withdrawal
* If true, the farm is frozen and no more deposits are allowed
*/
isFarmFrozen: number;
/**
* Indicates if the farm is a delegate farm
* If true, the farm is a delegate farm and the `delegate_authority` is set*
*/
isFarmDelegated: number;
padding0: Array<number>;
/**
* Withdraw authority for the farm, allowed to lock deposited funds and withdraw them
* Set to `default()` if unused (only the depositors can withdraw their funds)
*/
withdrawAuthority: PublicKey;
/**
* Delay between a user deposit and the moment it is considered as staked
* 0 if unused
*/
depositWarmupPeriod: number;
/** Delay between a user unstake and the ability to withdraw his deposit. */
withdrawalCooldownPeriod: number;
/** Total active stake of tokens in the farm (scaled from `Decimal` representation). */
totalActiveStakeScaled: BN;
/**
* Total pending stake of tokens in the farm (scaled from `Decimal` representation).
* (can be used by `withdraw_authority` but don't get rewards or fees)
*/
totalPendingStakeScaled: BN;
/** Total pending amount of tokens in the farm */
totalPendingAmount: BN;
/** Slashed amounts from early withdrawal */
slashedAmountCurrent: BN;
slashedAmountCumulative: BN;
slashedAmountSpillAddress: PublicKey;
/** Locking stake */
lockingMode: BN;
lockingStartTimestamp: BN;
lockingDuration: BN;
lockingEarlyWithdrawalPenaltyBps: BN;
depositCapAmount: BN;
scopePrices: PublicKey;
scopeOraclePriceId: BN;
scopeOracleMaxAge: BN;
pendingFarmAdmin: PublicKey;
strategyId: PublicKey;
padding: Array<BN>;
}
export interface FarmStateJSON {
farmAdmin: string;
globalConfig: string;
token: types.TokenInfoJSON;
rewardInfos: Array<types.RewardInfoJSON>;
numRewardTokens: string;
/** Data used to calculate the rewards of the user */
numUsers: string;
/**
* The number of token in the `farm_vault` staked (getting rewards and fees)
* Set such as `farm_vault.amount = total_staked_amount + total_pending_amount`
*/
totalStakedAmount: string;
farmVault: string;
farmVaultsAuthority: string;
farmVaultsAuthorityBump: string;
/**
* Only used for delegate farms
* Set to `default()` otherwise
*/
delegateAuthority: string;
/**
* Raw representation of a `TimeUnit`
* Seconds = 0, Slots = 1
*/
timeUnit: number;
/**
* Automatically set to true in case of a full authority withdrawal
* If true, the farm is frozen and no more deposits are allowed
*/
isFarmFrozen: number;
/**
* Indicates if the farm is a delegate farm
* If true, the farm is a delegate farm and the `delegate_authority` is set*
*/
isFarmDelegated: number;
padding0: Array<number>;
/**
* Withdraw authority for the farm, allowed to lock deposited funds and withdraw them
* Set to `default()` if unused (only the depositors can withdraw their funds)
*/
withdrawAuthority: string;
/**
* Delay between a user deposit and the moment it is considered as staked
* 0 if unused
*/
depositWarmupPeriod: number;
/** Delay between a user unstake and the ability to withdraw his deposit. */
withdrawalCooldownPeriod: number;
/** Total active stake of tokens in the farm (scaled from `Decimal` representation). */
totalActiveStakeScaled: string;
/**
* Total pending stake of tokens in the farm (scaled from `Decimal` representation).
* (can be used by `withdraw_authority` but don't get rewards or fees)
*/
totalPendingStakeScaled: string;
/** Total pending amount of tokens in the farm */
totalPendingAmount: string;
/** Slashed amounts from early withdrawal */
slashedAmountCurrent: string;
slashedAmountCumulative: string;
slashedAmountSpillAddress: string;
/** Locking stake */
lockingMode: string;
lockingStartTimestamp: string;
lockingDuration: string;
lockingEarlyWithdrawalPenaltyBps: string;
depositCapAmount: string;
scopePrices: string;
scopeOraclePriceId: string;
scopeOracleMaxAge: string;
pendingFarmAdmin: string;
strategyId: string;
padding: Array<string>;
}
export declare class FarmState {
readonly farmAdmin: PublicKey;
readonly globalConfig: PublicKey;
readonly token: types.TokenInfo;
readonly rewardInfos: Array<types.RewardInfo>;
readonly numRewardTokens: BN;
/** Data used to calculate the rewards of the user */
readonly numUsers: BN;
/**
* The number of token in the `farm_vault` staked (getting rewards and fees)
* Set such as `farm_vault.amount = total_staked_amount + total_pending_amount`
*/
readonly totalStakedAmount: BN;
readonly farmVault: PublicKey;
readonly farmVaultsAuthority: PublicKey;
readonly farmVaultsAuthorityBump: BN;
/**
* Only used for delegate farms
* Set to `default()` otherwise
*/
readonly delegateAuthority: PublicKey;
/**
* Raw representation of a `TimeUnit`
* Seconds = 0, Slots = 1
*/
readonly timeUnit: number;
/**
* Automatically set to true in case of a full authority withdrawal
* If true, the farm is frozen and no more deposits are allowed
*/
readonly isFarmFrozen: number;
/**
* Indicates if the farm is a delegate farm
* If true, the farm is a delegate farm and the `delegate_authority` is set*
*/
readonly isFarmDelegated: number;
readonly padding0: Array<number>;
/**
* Withdraw authority for the farm, allowed to lock deposited funds and withdraw them
* Set to `default()` if unused (only the depositors can withdraw their funds)
*/
readonly withdrawAuthority: PublicKey;
/**
* Delay between a user deposit and the moment it is considered as staked
* 0 if unused
*/
readonly depositWarmupPeriod: number;
/** Delay between a user unstake and the ability to withdraw his deposit. */
readonly withdrawalCooldownPeriod: number;
/** Total active stake of tokens in the farm (scaled from `Decimal` representation). */
readonly totalActiveStakeScaled: BN;
/**
* Total pending stake of tokens in the farm (scaled from `Decimal` representation).
* (can be used by `withdraw_authority` but don't get rewards or fees)
*/
readonly totalPendingStakeScaled: BN;
/** Total pending amount of tokens in the farm */
readonly totalPendingAmount: BN;
/** Slashed amounts from early withdrawal */
readonly slashedAmountCurrent: BN;
readonly slashedAmountCumulative: BN;
readonly slashedAmountSpillAddress: PublicKey;
/** Locking stake */
readonly lockingMode: BN;
readonly lockingStartTimestamp: BN;
readonly lockingDuration: BN;
readonly lockingEarlyWithdrawalPenaltyBps: BN;
readonly depositCapAmount: BN;
readonly scopePrices: PublicKey;
readonly scopeOraclePriceId: BN;
readonly scopeOracleMaxAge: BN;
readonly pendingFarmAdmin: PublicKey;
readonly strategyId: PublicKey;
readonly padding: Array<BN>;
static readonly discriminator: Buffer;
static readonly layout: any;
constructor(fields: FarmStateFields);
static fetch(c: Connection, address: PublicKey, programId?: PublicKey): Promise<FarmState | null>;
static fetchMultiple(c: Connection, addresses: PublicKey[], programId?: PublicKey): Promise<Array<FarmState | null>>;
static decode(data: Buffer): FarmState;
toJSON(): FarmStateJSON;
static fromJSON(obj: FarmStateJSON): FarmState;
}