Skip to content
docs

NativeStakingProtocolNear

Defined in: protocol-staking-native-near/src/protocol.ts:90

Native NEAR staking: deposit_and_stake into standard staking pools, unstake with the 4-epoch unbonding, withdraw_all once unlocked. See the package README for the full behaviour.

Fail-closed before anything is signed: the pool must be allowed (pools list or 'any'), carry a staking-pool factory suffix, run known staking-pool code, answer is_staking_paused with false, charge at most maxFee (now and as scheduled for the next epoch), and sit in the current and next validator sets (unless allowInactive). Balance checks count the prepaid gas the node buys upfront (fees.ts), and the stake leaves the largest exit’s worth of it on the account. An unstake withdraws an unlocked balance first in the same transaction so it is never locked again, and refuses to restart the wait of a balance still unbonding unless allowTimerReset. Exits (unstake, claim) need only the factory suffix and known (or factory-allowed) code, so a user can always leave a pool that was paused or raised its fee; the validator set and the epoch only decorate them.

new NativeStakingProtocolNear(account, config): NativeStakingProtocolNear

Defined in: protocol-staking-native-near/src/protocol.ts:111

IWalletAccountReadOnly | IWalletAccount

NativeStakingNearConfig

NativeStakingProtocolNear

StakingProtocol.constructor

protected readonly _account: IWalletAccountReadOnly | IWalletAccount

Defined in: core/dist/index-i6xtgDlq.d.ts:317

StakingProtocol._account


protected readonly _config: NativeStakingNearConfig

Defined in: core/dist/index-i6xtgDlq.d.ts:318

StakingProtocol._config


readonly concurrency: number

Defined in: protocol-staking-native-near/src/protocol.ts:96


readonly defaultPool: string | undefined

Defined in: protocol-staking-native-near/src/protocol.ts:92


readonly gas: object

Defined in: protocol-staking-native-near/src/protocol.ts:95

stake: bigint

unstake: bigint

withdraw: bigint


readonly maxFee: number

Defined in: protocol-staking-native-near/src/protocol.ts:93


readonly pools: NormalizedPools

Defined in: protocol-staking-native-near/src/protocol.ts:91


readonly reserve: bigint

Defined in: protocol-staking-native-near/src/protocol.ts:94


protected readonly rpc: NearRpc | undefined

Defined in: protocol-staking-native-near/src/protocol.ts:99

get network(): NearNetwork

Defined in: protocol-staking-native-near/src/protocol.ts:157

The configured network, else the account’s (near:testnet → testnet, anything else → mainnet).

NearNetwork

claimWithdrawals(options?): Promise<NearClaimResult>

Defined in: protocol-staking-native-near/src/protocol.ts:889

Withdraws unlocked balances: one withdraw_all per pool, with one approval when the account can send several transactions at once, else in order. If one fails midway, the error carries sent (the hashes that went out).

NearClaimOptions = {}

Promise<NearClaimResult>

StakingProtocol.claimWithdrawals


describeActivity(tx, ctx): ActivityItem | null

Defined in: protocol-staking-native-near/src/protocol.ts:900

Recognize one of this protocol’s own transactions in an address’s history and describe it for the wallet’s activity feed (“Supplied 100 USDC · Aave v3”). Return null when the transaction is not this protocol’s: the kit then asks the next module and finally falls back to send / receive / approve / contract call. Must be pure and synchronous: no network, no account state. The conformance suite feeds every module its recorded fixtures through this method.

ChainTx

DescribeActivityContext

ActivityItem | null

StakingProtocol.describeActivity


factoryOf(poolId): PoolFactory | null

Defined in: protocol-staking-native-near/src/protocol.ts:162

The factory a pool id belongs to on this network (local suffix check).

string

PoolFactory | null


getApr(options?): Promise<number>

Defined in: protocol-staking-native-near/src/protocol.ts:667

Delegator APR in percent: of pool, else defaultPool, else the network average after a typical fee.

string

Promise<number>

StakingProtocol.getApr


getEpoch(): Promise<NearEpoch>

Defined in: protocol-staking-native-near/src/protocol.ts:411

The epoch clock (height, start, blocks left, measured epoch length, estimated end).

Promise<NearEpoch>


getMaxStakeable(): Promise<bigint>

Defined in: protocol-staking-native-near/src/protocol.ts:657

What stake can send now: available − reserve − the stake’s upfront gas (never below 0).

Promise<bigint>


getNetworkStats(): Promise<NearNetworkStats>

Defined in: protocol-staking-native-near/src/protocol.ts:418

Network stake, measured epoch length and gross APR (treasury excluded).

Promise<NearNetworkStats>


getPool(id): Promise<NearPoolInfo>

Defined in: protocol-staking-native-near/src/protocol.ts:442

One pool with live checks (code hash, fee, pause, sets): what every write uses. Never cached.

string

Promise<NearPoolInfo>


getPools(ids): Promise<NearPoolInfo[]>

Defined in: protocol-staking-native-near/src/protocol.ts:473

Several pools with live checks, concurrency-limited; cached for display (DISPLAY_TTL_MS).

string[]

Promise<NearPoolInfo[]>


getStakedBalance(): Promise<NearStakedBalance>

Defined in: protocol-staking-native-near/src/protocol.ts:679

Staked across pools (balance), staked + unstaked (total), with the positions.

Promise<NearStakedBalance>

StakingProtocol.getStakedBalance


getWithdrawalRequests(options?): Promise<NearWithdrawalRequestsView>

Defined in: protocol-staking-native-near/src/protocol.ts:691

One request per pool holding an unstaked balance; ids are poolRequestId(pool).

string[]

Promise<NearWithdrawalRequestsView>

StakingProtocol.getWithdrawalRequests


listPools(): Promise<NearPoolInfo[]>

Defined in: protocol-staking-native-near/src/protocol.ts:425

Factory pools in the current or next validator set, by stake: light info from the validators RPC only (details: false).

Promise<NearPoolInfo[]>


listPositions(options?): Promise<NearPoolPosition[]>

Defined in: protocol-staking-native-near/src/protocol.ts:650

The account’s position in every listed, discovered and passed pool with a non-zero balance. Throws when discovery fails, so a lookup outage never reads as “no stake”; getStakedBalance, getWithdrawalRequests and claims carry on with the listed, passed and touched pools instead and say so with partial.

string[]

Promise<NearPoolPosition[]>


quoteClaimWithdrawals(options?): Promise<NearClaimQuote>

Defined in: protocol-staking-native-near/src/protocol.ts:880

One withdraw_all per pool with an unlocked balance (all, or ids); nothing is signed.

NearClaimOptions = {}

Promise<NearClaimQuote>

StakingProtocol.quoteClaimWithdrawals


quoteRequestWithdrawal(options): Promise<NearUnstakeQuote>

Defined in: protocol-staking-native-near/src/protocol.ts:825

The exact unstake transaction (with withdraw_all first when an unlocked balance waits); nothing is signed.

NearUnstakeOptions

Promise<NearUnstakeQuote>

StakingProtocol.quoteRequestWithdrawal


quoteStake(options): Promise<NearStakeQuote>

Defined in: protocol-staking-native-near/src/protocol.ts:735

The exact stake transaction, its fee and the pool’s live checks; nothing is signed.

NearStakeOptions

Promise<NearStakeQuote>

StakingProtocol.quoteStake


requestWithdrawal(options): Promise<NearUnstakeResult>

Defined in: protocol-staking-native-near/src/protocol.ts:830

Unstakes amount (or 'all') from the pool; claim it with claimWithdrawals after 4 epochs (~21–28 h).

NearUnstakeOptions

Promise<NearUnstakeResult>

StakingProtocol.requestWithdrawal


protected requireSigningAccount(methodName): IWalletAccount

Defined in: core/dist/index-i6xtgDlq.d.ts:330

The account, narrowed to a signing one, or a ReadOnlyAccountError naming the caller.

string

IWalletAccount

StakingProtocol.requireSigningAccount


stake(options): Promise<NearStakeResult>

Defined in: protocol-staking-native-near/src/protocol.ts:740

deposit_and_stake of exactly amount into the pool, after fresh checks; refuses when the plan differs from expected.

NearStakeOptions

Promise<NearStakeResult>

StakingProtocol.stake