Creates a Farms instance for farm API reads and transaction builders.
Optionalconfig: CallerConfig
Optional network, API-host, and access-token configuration.
Optionalapi: AftermathApi
Optional provider used by transaction builders. Reads do not require it.
Optional ReadonlyapiOptional provider used by transaction builders. Reads do not require it.
The mutable configuration used for subsequent requests.
Static ReadonlyconstantsThresholds used by the high-level reward and multiplier helpers.
Maximum human-readable lock multiplier exposed by the legacy helper,
represented as 2 for a 2x multiplier. Pool objects store the precise
value as an 18-decimal fixed-point bigint.
Minimum claimable reward amount, in the reward coin's base units.
Rewards below this threshold are reported as zero by
FarmsStakedPosition.rewardsEarned.
Fetches all existing staking pools registered within the indexer or farm API.
OptionalabortSignal: AbortSignal
Optional signal that cancels the API request.
An array of FarmsStakingPool objects.
Deprecated: Use getCreateStakingPoolTransactionV2() instead.
Builds a transaction to create a new staking pool (farming vault) on version 1 of the farm system.
Pool durations in milliseconds, fixed-point multiplier, minimum stake, coin type, and creator address.
A transaction object (or bytes) that can be signed and submitted.
Builds a transaction to create a new staking pool (farming vault) on version 2 of the farm system.
Pool durations in milliseconds, fixed-point multiplier, minimum stake, coin type, and creator address.
A transaction object (or bytes) that can be signed and submitted.
const tx = await farms.getCreateStakingPoolTransactionV2({
minLockDurationMs: 604800000, // 1 week
maxLockDurationMs: 31536000000, // 1 year
maxLockMultiplier: BigInt("2000000000000000000"), // 2.0x in 18-decimal fixed point
minStakeAmount: BigInt("1000000"),
stakeCoinType: "0x<coin_type>",
walletAddress: "0x<admin_address>"
});
// sign and submit the transaction
Fetches TVL and reward TVL for multiple farms in a single batch response.
When farmIds is omitted, the API returns summaries for all farms.
Optionalinputs: ApiFarmsSummaryBody
Optionally provide the farm IDs to include.
OptionalabortSignal: AbortSignal
An optional signal for cancelling the request.
TVL and reward TVL metrics for each requested farm.
Fetches user-specific farm interaction events (e.g., staked, unlocked, withdrew) with optional pagination.
Includes the user's walletAddress, along with cursor and limit for pagination.
A paginated set of events of type FarmUserEvent.
Fetches all staked positions owned by a given user.
An object containing the user's walletAddress.
An array of FarmsStakedPosition objects representing each of the user's staked positions.
Fetches all StakingPoolOneTimeAdminCapObjects that a given address owns.
These caps grant one-time admin privileges, typically for initializing reward coins.
An object containing the admin's walletAddress.
An array of StakingPoolOneTimeAdminCapObjects.
Fetches all StakingPoolOwnerCapObjects that a given address owns.
These caps grant the owner the ability to modify staking pool parameters.
An object containing the owner's walletAddress.
An array of StakingPoolOwnerCapObjects.
Retrieves the total value locked (TVL) of reward coins across specified farm IDs or all farms if none are specified.
Optionalinputs: { farmIds?: string[] }
An optional object containing an array of farmIds. If not provided, returns global reward TVL.
OptionalabortSignal: AbortSignal
Optional signal that cancels the API request.
A promise that resolves to the reward TVL as a number in the API's reporting currency.
Fetches a single staking pool by its objectId from the farm API/indexer.
An object containing the objectId of the staking pool.
OptionalabortSignal: AbortSignal
Optional signal that cancels the API request.
A FarmsStakingPool object representing the staking pool.
Fetches multiple staking pools by their objectIds.
An object containing an array of objectIds.
OptionalabortSignal: AbortSignal
Optional signal that cancels the API request.
An array of FarmsStakingPool instances corresponding to each objectId.
Retrieves the total value locked (TVL) in the specified farm IDs or in all farms if none are specified.
Optionalinputs: { farmIds?: string[] }
An optional object containing an array of farmIds to filter TVL by. If not provided, returns global TVL.
OptionalabortSignal: AbortSignal
Optional signal that cancels the API request.
A promise that resolves to the TVL as a number in the API's reporting currency.
StaticapiReturns the canonical Aftermath API host for a Sui network.
To target a custom or local host, pass baseUrl in CallerConfig to the
constructor instead.
The Sui network whose host to return.
The network's HTTPS or local HTTP API host.
StaticdefaultReturns the canonical Sui fullnode URL for a network.
The network whose fullnode URL to return. undefined
defaults to mainnet.
The network's fullnode URL.
High-level reads and transaction builders for Sui staking pools.
The class reads pools, positions, capabilities, TVL, summaries, and user events through the farm API. Its transaction methods delegate to
AftermathApi.Farms()and return unsigned transaction data. They do not sign or submit transactions. Pass anAftermathApiinstance to the constructor when you use those builders.Example