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.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NativeStakingProtocolNear(
account,config):NativeStakingProtocolNear
Defined in: protocol-staking-native-near/src/protocol.ts:111
Parameters
Section titled “Parameters”account
Section titled “account”IWalletAccountReadOnly | IWalletAccount
config
Section titled “config”Returns
Section titled “Returns”NativeStakingProtocolNear
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_account
Section titled “_account”
protectedreadonly_account:IWalletAccountReadOnly|IWalletAccount
Defined in: core/dist/index-i6xtgDlq.d.ts:317
Inherited from
Section titled “Inherited from”_config
Section titled “_config”
protectedreadonly_config:NativeStakingNearConfig
Defined in: core/dist/index-i6xtgDlq.d.ts:318
Inherited from
Section titled “Inherited from”concurrency
Section titled “concurrency”
readonlyconcurrency:number
Defined in: protocol-staking-native-near/src/protocol.ts:96
defaultPool
Section titled “defaultPool”
readonlydefaultPool:string|undefined
Defined in: protocol-staking-native-near/src/protocol.ts:92
readonlygas:object
Defined in: protocol-staking-native-near/src/protocol.ts:95
stake:
bigint
unstake
Section titled “unstake”unstake:
bigint
withdraw
Section titled “withdraw”withdraw:
bigint
maxFee
Section titled “maxFee”
readonlymaxFee:number
Defined in: protocol-staking-native-near/src/protocol.ts:93
readonlypools:NormalizedPools
Defined in: protocol-staking-native-near/src/protocol.ts:91
reserve
Section titled “reserve”
readonlyreserve:bigint
Defined in: protocol-staking-native-near/src/protocol.ts:94
protectedreadonlyrpc:NearRpc|undefined
Defined in: protocol-staking-native-near/src/protocol.ts:99
Accessors
Section titled “Accessors”network
Section titled “network”Get Signature
Section titled “Get Signature”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).
Returns
Section titled “Returns”Methods
Section titled “Methods”claimWithdrawals()
Section titled “claimWithdrawals()”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).
Parameters
Section titled “Parameters”options?
Section titled “options?”NearClaimOptions = {}
Returns
Section titled “Returns”Promise<NearClaimResult>
Overrides
Section titled “Overrides”StakingProtocol.claimWithdrawals
describeActivity()
Section titled “describeActivity()”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.
Parameters
Section titled “Parameters”ChainTx
DescribeActivityContext
Returns
Section titled “Returns”ActivityItem | null
Overrides
Section titled “Overrides”StakingProtocol.describeActivity
factoryOf()
Section titled “factoryOf()”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).
Parameters
Section titled “Parameters”poolId
Section titled “poolId”string
Returns
Section titled “Returns”PoolFactory | null
getApr()
Section titled “getApr()”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.
Parameters
Section titled “Parameters”options?
Section titled “options?”string
Returns
Section titled “Returns”Promise<number>
Overrides
Section titled “Overrides”getEpoch()
Section titled “getEpoch()”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).
Returns
Section titled “Returns”Promise<NearEpoch>
getMaxStakeable()
Section titled “getMaxStakeable()”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).
Returns
Section titled “Returns”Promise<bigint>
getNetworkStats()
Section titled “getNetworkStats()”getNetworkStats():
Promise<NearNetworkStats>
Defined in: protocol-staking-native-near/src/protocol.ts:418
Network stake, measured epoch length and gross APR (treasury excluded).
Returns
Section titled “Returns”Promise<NearNetworkStats>
getPool()
Section titled “getPool()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<NearPoolInfo>
getPools()
Section titled “getPools()”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).
Parameters
Section titled “Parameters”string[]
Returns
Section titled “Returns”Promise<NearPoolInfo[]>
getStakedBalance()
Section titled “getStakedBalance()”getStakedBalance():
Promise<NearStakedBalance>
Defined in: protocol-staking-native-near/src/protocol.ts:679
Staked across pools (balance), staked + unstaked (total), with the positions.
Returns
Section titled “Returns”Promise<NearStakedBalance>
Overrides
Section titled “Overrides”StakingProtocol.getStakedBalance
getWithdrawalRequests()
Section titled “getWithdrawalRequests()”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).
Parameters
Section titled “Parameters”options?
Section titled “options?”pools?
Section titled “pools?”string[]
Returns
Section titled “Returns”Promise<NearWithdrawalRequestsView>
Overrides
Section titled “Overrides”StakingProtocol.getWithdrawalRequests
listPools()
Section titled “listPools()”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).
Returns
Section titled “Returns”Promise<NearPoolInfo[]>
listPositions()
Section titled “listPositions()”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.
Parameters
Section titled “Parameters”options?
Section titled “options?”pools?
Section titled “pools?”string[]
Returns
Section titled “Returns”Promise<NearPoolPosition[]>
quoteClaimWithdrawals()
Section titled “quoteClaimWithdrawals()”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.
Parameters
Section titled “Parameters”options?
Section titled “options?”NearClaimOptions = {}
Returns
Section titled “Returns”Promise<NearClaimQuote>
Overrides
Section titled “Overrides”StakingProtocol.quoteClaimWithdrawals
quoteRequestWithdrawal()
Section titled “quoteRequestWithdrawal()”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.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<NearUnstakeQuote>
Overrides
Section titled “Overrides”StakingProtocol.quoteRequestWithdrawal
quoteStake()
Section titled “quoteStake()”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.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<NearStakeQuote>
Overrides
Section titled “Overrides”requestWithdrawal()
Section titled “requestWithdrawal()”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).
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<NearUnstakeResult>
Overrides
Section titled “Overrides”StakingProtocol.requestWithdrawal
requireSigningAccount()
Section titled “requireSigningAccount()”
protectedrequireSigningAccount(methodName):IWalletAccount
Defined in: core/dist/index-i6xtgDlq.d.ts:330
The account, narrowed to a signing one, or a ReadOnlyAccountError naming the caller.
Parameters
Section titled “Parameters”methodName
Section titled “methodName”string
Returns
Section titled “Returns”IWalletAccount
Inherited from
Section titled “Inherited from”StakingProtocol.requireSigningAccount
stake()
Section titled “stake()”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.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<NearStakeResult>