UNPKG

aftermath-ts-sdk

Version:
199 lines 9.02 kB
import { Caller } from "../../general/utils/caller"; import { Balance, CallerConfig, CoinType, CoinsToBalance, FarmsStakedPositionObject, FarmsVersion, SuiAddress, Timestamp } from "../../types"; import { FarmsStakingPool } from "./farmsStakingPool"; import { AftermathApi } from "../../general/providers"; /** * The `FarmsStakedPosition` class represents a user's individual staked position * in a particular staking pool. It provides methods to query position details, * calculate potential rewards, lock/unlock stake, and build transactions * for depositing, unstaking, or harvesting rewards. */ export declare class FarmsStakedPosition extends Caller { stakedPosition: FarmsStakedPositionObject; private readonly Provider?; /** * The timestamp (in ms) when rewards were last harvested for this position, possibly overriding the * on-chain data if provided in the constructor. */ readonly trueLastHarvestRewardsTimestamp: Timestamp; /** * Creates a `FarmsStakedPosition` instance for a user's staked position in a farm. * * @param stakedPosition - The on-chain data object representing the user's staked position. * @param trueLastHarvestRewardsTimestamp - Optionally overrides the last harvest time from the on-chain data. * @param config - Optional configuration for the underlying `Caller`. * @param Provider - Optional `AftermathApi` instance for transaction building. */ constructor(stakedPosition: FarmsStakedPositionObject, trueLastHarvestRewardsTimestamp?: Timestamp | undefined, config?: CallerConfig, Provider?: AftermathApi | undefined); /** * Returns the version of the farm system that this position belongs to (1 or 2). */ version: () => FarmsVersion; /** * Checks whether the position is still locked, based on the current time and the lock parameters. * * @param inputs - Contains a `FarmsStakingPool` instance to check for system constraints. * @returns `true` if the position is locked; otherwise, `false`. */ isLocked: (inputs: { stakingPool: FarmsStakingPool; }) => boolean; /** * Checks whether the position has a non-zero lock duration. * * @returns `true` if the position was created with a lock duration > 0. */ isLockDuration: () => boolean; /** * Computes the timestamp (in ms) at which this position's lock will end. * * @returns The unlock timestamp (lock start + lock duration). */ unlockTimestamp: () => number; /** * Computes the user's accrued rewards for each reward coin in this position, * returned as a `CoinsToBalance` object keyed by coin type. * * @param inputs - Contains a reference to the `FarmsStakingPool`. * @returns A mapping from `coinType` to the amount of earned rewards. */ rewardCoinsToClaimableBalance: (inputs: { stakingPool: FarmsStakingPool; }) => CoinsToBalance; /** * Lists all reward coin types associated with this position. * * @returns An array of `CoinType` strings representing the reward coins. */ rewardCoinTypes: () => CoinType[]; /** * Returns only the reward coin types that currently have a non-zero claimable balance. * * @param inputs - Contains a reference to the `FarmsStakingPool`. * @returns An array of `CoinType` strings that have pending rewards > 0. */ nonZeroRewardCoinTypes: (inputs: { stakingPool: FarmsStakingPool; }) => CoinType[]; /** * Retrieves the reward coin record for a specific coin type in this position. * * @param inputs - Must contain a `coinType` string to look up. * @throws If the coin type is not found in this position. * @returns The reward coin object from the position. */ rewardCoin: (inputs: { coinType: CoinType; }) => import("./farmsTypes").FarmsStakedPositionRewardCoin; /** * Checks if this position has any claimable rewards across all reward coin types. * * @param inputs - Contains a reference to the `FarmsStakingPool`. * @returns `true` if there are unclaimed rewards; otherwise, `false`. */ hasClaimableRewards: (inputs: { stakingPool: FarmsStakingPool; }) => boolean; /** * Calculates the current amount of earned rewards for a specific coin type, * factoring in any emission constraints and the pool's actual reward availability. * * @param inputs - Contains the `coinType` to check and a reference to the `FarmsStakingPool`. * @returns The total `BigInt` amount of rewards earned for the specified coin type. */ rewardsEarned: (inputs: { coinType: CoinType; stakingPool: FarmsStakingPool; }) => Balance; /** * Updates the position's reward calculations based on the pool's current * emission state, effectively "syncing" the on-chain logic into this local * representation. Also checks if the lock duration has elapsed. * * @param inputs - Contains a reference to the `FarmsStakingPool`. * @remarks This method is typically called before computing `rewardsEarned()`. */ updatePosition: (inputs: { stakingPool: FarmsStakingPool; }) => void; /** * Builds a transaction to deposit additional principal into this staked position. * * @param inputs - Contains `depositAmount`, the `walletAddress` performing the deposit, and optional sponsorship. * @returns A transaction object (or bytes) that can be signed and executed to increase stake. */ getDepositPrincipalTransaction(inputs: { depositAmount: Balance; walletAddress: SuiAddress; isSponsoredTx?: boolean; }): Promise<import("@mysten/sui/transactions").Transaction>; /** * Builds a transaction to unstake this entire position, optionally claiming SUI as afSUI. * * @param inputs - Contains `walletAddress`, the `FarmsStakingPool` reference, and optional `claimSuiAsAfSui`. * @returns A transaction that can be signed and executed to fully withdraw principal and possibly rewards. */ getUnstakeTransaction(inputs: { walletAddress: SuiAddress; stakingPool: FarmsStakingPool; claimSuiAsAfSui?: boolean; }): Promise<import("@mysten/sui/transactions").Transaction>; /** * Builds a transaction to lock this position for a specified duration, increasing its lock multiplier (if any). * * @param inputs - Contains the `lockDurationMs` and the `walletAddress`. * @returns A transaction that can be signed and executed to lock the position. */ getLockTransaction(inputs: { lockDurationMs: Timestamp; walletAddress: SuiAddress; }): Promise<import("@mysten/sui/transactions").Transaction>; /** * Builds a transaction to re-lock this position (renew lock duration) at the current multiplier. * * @param inputs - Contains the `walletAddress`. * @returns A transaction that can be signed and executed to extend or refresh the lock. */ getRenewLockTransaction(inputs: { walletAddress: SuiAddress; }): Promise<import("@mysten/sui/transactions").Transaction>; /** * Builds a transaction to unlock this position, removing any lock-based multiplier. * * @param inputs - Contains the `walletAddress`. * @returns A transaction that can be signed and executed to unlock the position immediately. */ getUnlockTransaction(inputs: { walletAddress: SuiAddress; }): Promise<import("@mysten/sui/transactions").Transaction>; /** * Builds a transaction to harvest (claim) the rewards from this position, * optionally receiving SUI as afSUI. * * @param inputs - Includes the `walletAddress`, the `FarmsStakingPool`, and optional `claimSuiAsAfSui`. * @returns A transaction that can be signed and executed to claim accrued rewards. */ getHarvestRewardsTransaction(inputs: { walletAddress: SuiAddress; stakingPool: FarmsStakingPool; claimSuiAsAfSui?: boolean; }): Promise<import("@mysten/sui/transactions").Transaction>; /** * Calculates the total base + multiplier rewards from time t0 for this position, * ensuring that multiplier rewards only apply during the locked period. * * @param inputs - Contains updated `rewardsAccumulatedPerShare`, the position’s `multiplierRewardsDebt`, and the pool’s `emissionEndTimestamp`. * @returns A tuple `[baseRewards, multiplierRewards]`. */ private calcTotalRewardsFromTimeT0; /** * Determines if this position is unlocked based on the lock end timestamp, the emission end timestamp, * or a forced unlock condition in the pool. */ private isUnlocked; /** * Provides access to the `Farms` provider in the `AftermathApi`. */ private useProvider; } //# sourceMappingURL=farmsStakedPosition.d.ts.map