aftermath-ts-sdk - v3.3.3
    Preparing search index...

    A local view of one user's staked position.

    The class exposes lock state, reward accounting, and version-aware builders for depositing, withdrawing, locking, unlocking, unstaking, and harvesting. Reward and lock calculations use the supplied pool view and do not fetch fresh data. Transaction builders require an AftermathApi provider and return unsigned transaction data.

    Hierarchy (View Summary)

    Index

    Optional provider required by transaction builders.

    config: CallerConfig

    The mutable configuration used for subsequent requests.

    Normalized object data for the user's position.

    trueLastHarvestRewardsTimestamp: number

    The reward timestamp supplied by the constructor, or the position's stored last-harvest timestamp when no override was supplied.

    • Builds a version-aware transaction to deposit additional principal.

      The position, pool, and stake coin IDs are taken from this instance. The amount is in stake-coin base units. The transaction does not submit itself.

      Parameters

      • inputs: { depositAmount: bigint; isSponsoredTx?: boolean; walletAddress: string }

        Deposit amount, signing wallet, and optional sponsorship.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Builds a version-aware transaction to harvest this position's rewards.

      The builder includes only reward types with a positive locally claimable balance. It can request SUI as afSUI when that option is supported.

      Parameters

      • inputs: {
            claimSuiAsAfSui?: boolean;
            stakingPool: FarmsStakingPool;
            walletAddress: string;
        }

        Matching pool view, signing wallet, and optional SUI-to-afSUI claim flag.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Builds a version-aware transaction to lock this position for a duration.

      The duration is in milliseconds and is validated against the pool's lock range when the transaction executes. V1 and V2 builders are selected from the position version.

      Parameters

      • inputs: { lockDurationMs: number; walletAddress: string }

        Lock duration and signing wallet.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Builds a version-aware transaction to renew this position's lock.

      The on-chain command refreshes the lock without accepting a new duration.

      Parameters

      • inputs: { walletAddress: string }

        Signing wallet.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Builds a version-aware transaction to unlock this position.

      The contract may reject the command while the position is still locked. Emission end and the pool's forced-open flag are part of the local lock checks used by the façade, but on-chain validation remains authoritative.

      Parameters

      • inputs: { walletAddress: string }

        Signing wallet.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Builds a version-aware transaction that withdraws this entire position and destroys it.

      The builder includes reward types with a positive claimable balance before it withdraws principal and appends the destroy command. Strict pools still require the position to be unlocked when the transaction executes.

      Parameters

      • inputs: {
            claimSuiAsAfSui?: boolean;
            stakingPool: FarmsStakingPool;
            walletAddress: string;
        }

        Matching pool view, signing wallet, and optional SUI-to-afSUI claim flag.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Builds a version-aware transaction to withdraw part of the principal.

      Unlike getUnstakeTransaction, this operation keeps the position object. The amount is in stake-coin base units, and the matching pool view is used by the on-chain validation path.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool; walletAddress: string; withdrawAmount: bigint }

        Withdraw amount, matching pool view, and signing wallet.

      Returns Promise<Transaction>

      An unsigned transaction that can be signed and executed.

      An error if no AftermathApi instance was provided.

    • Checks whether the position stores a non-zero lock duration.

      Returns boolean

      true if the position was created with a lock duration > 0.

    • Checks whether the position is currently locked for this pool.

      The result is false when the lock has expired, the pool's emission period has ended, or the pool is forcibly open. It uses Date.now() and does not perform a network read.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool }

        Pool view used for emission-end and forced-unlock rules.

      Returns boolean

      true if the position is locked; otherwise, false.

    • Checks whether the position is locked under relaxed pool enforcement.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool }

        Contains a FarmsStakingPool instance to check lock state and enforcement.

      Returns boolean

      true if locked with relaxed enforcement; otherwise, false.

    • Checks whether the position is locked under strict pool enforcement.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool }

        Contains a FarmsStakingPool instance to check lock state and enforcement.

      Returns boolean

      true if locked with strict enforcement; otherwise, false.

    • Returns reward coin types with a positive claimable balance.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool }

        Contains a reference to the FarmsStakingPool.

      Returns string[]

      An array of CoinType strings that have pending rewards > 0.

    • Computes the claimable amount for each reward coin in this position.

      The returned map uses reward coin types as keys and base-unit bigint amounts as values. It applies the minimum claim threshold and available pool balance checks used by rewardsEarned.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool }

        Pool view used to validate each reward balance.

      Returns CoinsToBalance

      A mapping from coinType to claimable base-unit balance.

    • Lists all reward coin types associated with this position.

      Returns string[]

      An array of CoinType strings representing the reward coins.

    • Returns the currently claimable amount for one reward coin.

      This local calculation adds base and multiplier rewards. It returns zero when the pool has no actual balance, the amount is below Farms.constants.minRewardsToClaim, or the amount exceeds the pool's available balance. It does not call updatePosition() automatically.

      Parameters

      • inputs: { coinType: string; stakingPool: FarmsStakingPool }

        Reward coin type and the matching pool view.

      Returns bigint

      The claimable amount in reward-coin base units.

      Error with "Invalid coin type" when either object has no matching reward record.

    • Computes the timestamp in milliseconds at which this position's lock ends.

      Returns number

      The unlock timestamp (lock start + lock duration).

    • Updates this position's local reward accounting from a pool snapshot.

      The method emits completed pool intervals, clamps a stale lock to the pool's maximum duration and multiplier, adds reward records introduced by the pool, updates reward debts, and records the current timestamp. It does not fetch from the network and does not automatically call the on-chain unlock operation when the lock expires.

      Parameters

      • inputs: { stakingPool: FarmsStakingPool }

        Pool snapshot used for emission and per-share calculations.

      Returns void

      Call this method before rewardsEarned() when the local position data is stale.

    • Returns the canonical Aftermath API host for a Sui network.

      To target a custom or local host, pass baseUrl in CallerConfig to the constructor instead.

      Parameters

      • network: SuiNetwork

        The Sui network whose host to return.

      Returns string

      The network's HTTPS or local HTTP API host.