Runner · Reference
PluginContext
The ctx passed to decide().
Derived from packages/runtime-core/src/types.ts
Every tick, the runtime builds a fresh PluginContext and hands it to your decide(). It is everything your strategy gets to see and the only sanctioned way to touch the outside world.
Read fromctx, returnAction[]. Side effects go throughctx.stateonly — never RPC, keys, or atxyou build yourself.
The six fields
vault:Vault— fresh on-chain vault snapshot at trigger time (SDKVaultclass). Getters below.suiClient:SuiClient— the runtime's shared client, for SDK read helpers. A plugin does not create its own.now:number—Date.now()injected for testability. Call this, neverDate.now()directly.state:PluginStateAPI— KV store scoped by pluginname. See Plugin state API.logger:Logger— pre-bound withpluginName/vaultId.debug/info/warn/error, plusbind(fields)andtiming(name, fn).lifecycle:LifecycleContext—{ closures: ClosureEvent[] }, the positions that closed since the last tick (delta semantics).[]on the first tick, when nothing closed, on dry-runs, and after a restart.
ctx.vault — read getters
The vault state, decoded. All bigint unless noted.
quoteBalance: free quote held by the vault.plpBalance: PLP balance.totalShares: total LP shares outstanding.nav: net asset value.navPerShare: NAV per share.aggregateExposure: summed exposure across open positions.highWaterMark: HWM for performance fees.lastSnapshotTs: ts of the last NAV snapshot.pendingDepositsTotal/pendingWithdrawalSharesTotal: queued deposits (quote) and withdrawals (shares).accruedFeesQuote/lastCrystallizationTs: fees accrued and when they last crystallized.predictManagerId:string | null— the vault's Predict manager object.authorizedWitnessType:string— the witness type that gates strategy calls.strategyPermissions: the raw permission bitfield (decoded by thecan*getters below).paused/strategyPaused:boolean— governance pause and strategy pause flags.pauseReason:number.pauseTs:bigint | null.governanceAdmin/emergencyAdmin:string— admin addresses.trackedMarketKeys:MarketKey[]— open binary positions ({ oracle_id, expiry, strike, direction, is_up }).trackedRangeKeys:RangeKey[]— open range positions ({ oracle_id, expiry, lower_strike, higher_strike }).navParams:NavParams—{ snapshot_interval_seconds, deposit_cooldown_seconds, withdrawal_cooldown_seconds }.riskParams:RiskParamsState— the anti-rug caps{ max_position_bps, max_aggregate_exposure_bps, max_drawdown_bps, max_share_concentration_bps }.feeParams:FeeParamsState—{ performance_fee_bps, management_fee_bps_annual, entry_fee_bps, exit_fee_bps, platform_split_bps }.uniqueOracleIds:string[]— deduplicated, sorted oracle IDs across both key lists.rawState:VaultState— the full decoded struct, if you need a field with no getter.
ctx.vault — computed getters
Derived arithmetic, so you don't re-roll it (and the bugs that come with it).
isFrozen:boolean—paused || strategyPaused. If true, don't bother trading.maxSinglePosition:bigint—nav × max_position_bps / 10_000. Larger trades abort withEPositionTooLarge.maxAggregateExposure:bigint—nav × max_aggregate_exposure_bps / 10_000. Crossing it aborts withEExposureLimitExceeded.exposureHeadroom:bigint—maxAggregateExposure − aggregateExposure, clamped>= 0n. Size new positions against this.openPositionsCount:number—trackedMarketKeys.length + trackedRangeKeys.length.timeSinceLastSnapshotMs(atMs?):number— ms since the last NAV snapshot;POSITIVE_INFINITYif never snapshotted. Passctx.nowto align with the tick.
ctx.vault — permission getters
Each is a boolean decoded from strategyPermissions (the full Permissions bitfield). Use one as a pre-flight before returning an action. The runtime's executor re-checks before submitting and the vault enforces on-chain too, so a missing check costs one rejected tick (no gas, no chain mutation).
canMintBinary/canRedeemBinary/canMintRange/canRedeemRangecanSupplyPlp/canWithdrawPlp/canPmDeposit/canPmWithdrawgrantedPermissions:PermissionName[]— every permission currently granted, for logging and error messages.
Next: the Actions you return, and the Result and error you get back.