{"interpretation":{"scope":"Acceptance specification for one TEST staking contract and its internal, non-transferable points. No contract, supply, address, pool, reward funding, or liquidity parameters are selected here.","authority":"The emission rule and requirements are supplied by the task. Formulas, examples, and bounds below are mathematical deductions and normative acceptance criteria, not claims about deployed software or requester-selected economics. No external factual claims are relied upon.","units":"Stake is an integer number of TEST base units; time is integer elapsed seconds from a nondecreasing chain timestamp; points use a declared smallest point unit. R is a nonnegative integer number of point units emitted per second for the entire nonempty pool, not per staked token. Rates and Q below are test parameters only.","idealRule":"On every half-open interval [a,b) with constant user stake s_u, total stake S and global rate R, ideal increment is R*(b-a)*s_u/S if S>0, otherwise zero. A timestamped action settles [lastTimestamp,t) using old values before applying its changes; actions at the same timestamp accrue zero between them.","choices":"A fixed rate or an authorized configurable rate both satisfy this specification. The implementation must disclose which, the actual rate and its units, Q, supported TEST transfer behavior, integer widths, and enforced arithmetic limits. All outputs are internal accounting points, not a promise of token rewards."},"accountingModel":{"state":"Q is a positive integer precision scale. Store total stake S, per-user stake s[u], global accumulator A in scaled point units per stake base unit, last global settlement timestamp T, and for each user checkpoint A_u and accrued scaled points B_u. Initialize S=A=0 and T to initialization time; initialize a new user's checkpoint to current A before crediting any stake, with B_u=0.","globalSettlement":"At timestamp t>=T, let dt=t-T. If S>0, set A := A + floor(R*dt*Q/S); if S=0 leave A unchanged. In both cases set T := t. This discards empty-pool emissions and prevents their later allocation. Record any rate change only after this settlement, using the old R.","userSettlement":"After global settlement and before changing s[u], set B_u := B_u + s[u]*(A-A_u), then A_u := A. B_u is retained in scaled point units, including fractional point units, even after full withdrawal; do not round B_u at each checkpoint. Other users' checkpoints may remain lazy. No accumulator increment or points can be retroactively assigned to a newly deposited stake.","mutations":"For a positive deposit, settle global and user, transfer an exactly received amount, then credit exactly that amount to s[u] and S atomically. For a positive withdrawal no greater than s[u], settle global and user, debit s[u] and S and transfer exactly that amount atomically. An authorized rate update settles global at the old rate before storing the new rate; lazy user settlement remains valid. A zero-amount action must either revert without state change or settle consistently without changing stake. The contract must not reset accumulated points on exit.","view":"At query timestamp t, virtually compute A* = A + (S>0 ? floor(R*(t-T)*Q/S) : 0), without changing storage. pendingScaled(u) = B_u + s[u]*(A*-A_u); pendingPoints(u) = floor(pendingScaled(u)/Q). The former includes stored and uncheckpointed points; a view called claimable or earned must clearly specify whether it includes both. A fractional remainder pendingScaled mod Q remains credited and carries into future intervals. Views and a transaction settled at the same timestamp agree, subject to the same integer display conversion.","roundingAndConservation":"Partition time at every global settlement, stake change and rate change; include one virtual settlement at the observation timestamp. For each nonempty interval j, let d_j=floor(R_j*dt_j*Q/S_j) and e_j=R_j*dt_j*Q-S_j*d_j, so 0<=e_j<S_j. In scaled point units, sum over all users of accrued plus virtual pending equals sum_j S_j*d_j; hence ideal emitted points E=sum_j R_j*dt_j equal aggregate scaled points divided by Q plus sum_j e_j/Q. Empty intervals add zero to both. For user u, ideal minus represented scaled points/Q is sum over nonempty j of s[u,j]*e_j/(S_j*Q), nonnegative; it is zero when the user has no nonzero-stake intervals and otherwise strictly less than sum over those intervals of s[u,j]/Q. Aggregate loss is sum_j e_j/Q < sum_j S_j/Q for nonempty intervals. If only integer pendingPoints are summed for N users, display flooring adds a nonnegative loss strictly less than N point units; retain remainders internally. Frequent settlements can increase dust; no universal fixed bound independent of settlement count and stakes is claimed. A zero rate adds no points. Exact rational comparisons or cross multiplication must be used in tests.","arithmetic":"Products, sums, timestamp differences, accumulator growth, and user credits must not silently wrap or truncate. Use checked arithmetic and sufficiently wide intermediates or full-precision multiplication/division; document and enforce bounds on rate, elapsed time, stake, Q, and cumulative operation so valid supported actions and views do not overflow. A reverting out-of-range operation must be atomic and must never silently reduce points or principal."},"invariants":["S equals the sum of all recorded user stakes, and each stake is nonnegative. Only a user's authorized deposit or withdrawal changes that user's stake; an authorized rate update and arbitrary third-party calls cannot move principal or modify user balances except as explicitly authorized by the user.","Recorded principal for each user equals the sum of their successful credited deposits minus successful withdrawals. The contract's TEST balance is at least S under the supported exact-transfer, non-rebasing token behavior; unsolicited transfers are surplus and never change S or points. Any surplus recovery must leave the balance at least S and cannot alter user principal or points.","Deposit and withdrawal must use safe token-call handling: failed or false-returning transfers revert the whole operation; supported no-return calls may succeed only when the expected balance movement is verified. Require exact received deposit and exact contract debit and recipient credit on withdrawal, or otherwise reject the token/transaction; fee-on-transfer, rebasing or other non-exact behavior is outside supported behavior. No failed transfer may leave accounting changes behind.","Protect all relevant external entry points against token-callback reentrancy, including cross-function reentrancy. Update accounting before outgoing external calls, check outcomes, and ensure any callback cannot double-withdraw, gain stake without payment, manipulate rate or duplicate points; a reverted call rolls back all its effects.","Only a specifically authorized role can change R if a setter exists; unauthorized attempts revert without effects. Rate changes, deposits and withdrawals cannot apply a new rate or balance to earlier time. If rate is immutable there is no rate-changing entry point.","A, each B_u, and pendingScaled(u) cannot decrease with time or successful stake/rate actions, assuming nonnegative R and no explicit points redemption or burn; no redemption or burn is part of this specification. Exiting preserves all prior points, including fractional remainder.","For each interval, no points are earned while S=0. Total represented points never exceed total ideal nonempty-pool emissions, with the exact dust identity and display bound specified in accountingModel."],"testVectors":{"conventions":"Independent fresh deployments at t=0, A=0, T=0, Q=1200000, and rate 12 point units/second unless changed. TEST amounts are base units; points are point units. Stakes and points listed are immediately after each action or observation at that timestamp, including virtual pending. A and B are exact integer scaled accounting. In these vectors each accumulator increment divides exactly, so tolerance is zero, including integer-display rounding. Observe is read-only; actions are ordered as listed even at the same timestamp.","cases":[{"name":"one staker","steps":[{"t":0,"action":"A deposits 10","stakes":{"A":10},"points":{"A":0},"aggregate":0,"tolerance":0},{"t":10,"action":"observe","stakes":{"A":10},"points":{"A":120},"aggregate":120,"tolerance":0}]},{"name":"unequal simultaneous stakes","steps":[{"t":0,"action":"A deposits 1","stakes":{"A":1,"B":0},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":0,"action":"B deposits 3","stakes":{"A":1,"B":3},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":10,"action":"observe","stakes":{"A":1,"B":3},"points":{"A":30,"B":90},"aggregate":120,"tolerance":0}]},{"name":"staggered entry","steps":[{"t":0,"action":"A deposits 1","stakes":{"A":1,"B":0},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":5,"action":"B deposits 1","stakes":{"A":1,"B":1},"points":{"A":60,"B":0},"aggregate":60,"tolerance":0},{"t":10,"action":"observe","stakes":{"A":1,"B":1},"points":{"A":90,"B":30},"aggregate":120,"tolerance":0}]},{"name":"partial then full exit","steps":[{"t":0,"action":"A deposits 3","stakes":{"A":3,"B":0},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":0,"action":"B deposits 1","stakes":{"A":3,"B":1},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":4,"action":"A withdraws 2","stakes":{"A":1,"B":1},"points":{"A":36,"B":12},"aggregate":48,"tolerance":0},{"t":8,"action":"A withdraws 1","stakes":{"A":0,"B":1},"points":{"A":60,"B":36},"aggregate":96,"tolerance":0},{"t":10,"action":"observe","stakes":{"A":0,"B":1},"points":{"A":60,"B":60},"aggregate":120,"tolerance":0}]},{"name":"empty pool and re-entry","steps":[{"t":0,"action":"A deposits 2","stakes":{"A":2,"B":0},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":5,"action":"A withdraws 2","stakes":{"A":0,"B":0},"points":{"A":60,"B":0},"aggregate":60,"tolerance":0},{"t":15,"action":"B deposits 2","stakes":{"A":0,"B":2},"points":{"A":60,"B":0},"aggregate":60,"tolerance":0},{"t":20,"action":"observe","stakes":{"A":0,"B":2},"points":{"A":60,"B":60},"aggregate":120,"tolerance":0},{"t":20,"action":"A deposits 2 again","stakes":{"A":2,"B":2},"points":{"A":60,"B":60},"aggregate":120,"tolerance":0},{"t":25,"action":"observe","stakes":{"A":2,"B":2},"points":{"A":90,"B":90},"aggregate":180,"tolerance":0}]},{"name":"rate change if configurable","steps":[{"t":0,"action":"A deposits 1","stakes":{"A":1,"B":0},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":0,"action":"B deposits 3","stakes":{"A":1,"B":3},"points":{"A":0,"B":0},"aggregate":0,"tolerance":0},{"t":4,"action":"authorized rate update from 12 to 20","stakes":{"A":1,"B":3},"points":{"A":12,"B":36},"aggregate":48,"tolerance":0},{"t":7,"action":"observe","stakes":{"A":1,"B":3},"points":{"A":27,"B":81},"aggregate":108,"tolerance":0}]}],"fractionalRoundingExample":"Separate test with Q=10, R=1, A and B each stake 3 at t=0. At t=1, d=floor(10/6)=1, each has pendingScaled=3, displayed points 0, and aggregate represented points 0.6 versus ideal 1; e=4, aggregate dust=0.4. After an actual settlement at t=1 and another at t=2, each has pendingScaled=6 and displayed 0; aggregate represented 1.2, ideal 2, dust 0.8. At t=4 with a single further settlement over [2,4), d=floor(20/6)=3; each has pendingScaled=15, displayed 1 with remainder 5; aggregate represented 3, ideal 4, dust 1. This illustrates per-settlement loss and preserved user fractions; test exact scaled values, not only displayed integers."},"contractReadRequirements":{"mandatory":["Read TEST token address, total staked S, account stake s[u], current global rate R and its units, and the precision Q or an explicitly documented fixed scale.","Read each account's total accrued plus currently pending points at the queried block timestamp. Provide pendingScaled or an equivalent view exposing the fractional remainder, and an integer points view with documented flooring and units. A zero address/account with no stake returns a defined result.","Expose whether rate is immutable or configurable and, if configurable, the role/address authorized to change it. Expose or document supported token behavior and transaction methods needed for deposit and withdrawal."],"events":"Emit successful deposit and withdrawal events with indexed user, amount and resulting user stake and total stake, and, if configurable, a rate-change event with old and new R. Event block timestamps identify settlement boundaries; events are not a substitute for current pending-points views. Emit only after success; reverted transactions leave no effective event. Event naming and extra fields are implementation choices."},"reviewChecks":["Implement a reference model using unbounded integers for A, B and dust, plus exact rational ideal shares. Fuzz nondecreasing timestamps, zero and positive rates, varied stake sizes, repeated same-time operations, deposits, partial/full exits, re-entry and authorized rate changes; compare every user view, stake, S and aggregate with the model after every action. Exercise both rate modes when supported.","For each generated interval verify the exact remainder identity, user error bound and aggregate conservation bound in accountingModel. Sum scaled balances across every participant, including exited accounts. Also test integer display loss and fractional carry; compare views to settlement at the same timestamp.","Fuzz an empty pool over long intervals, including rate changes while empty, then deposit and verify no historical empty-period emission is credited. Verify new and re-entering users cannot acquire earlier accumulator growth.","Exercise zero rate, repeated same-timestamp operations, non-divisible ratios and settlement frequency, minimum and documented maximum amounts, elapsed time, Q and rates; check arithmetic limits, reverts and atomicity. A timestamp decrease, if possible in the test harness, must not accrue or wrap.","Use adversarial TEST mocks for false return, no return, revert, insufficient allowance/balance, fee on transfer, unexpected balance changes and callback reentrancy into every mutating method. Verify exact principal movement, failed-operation rollback, no duplicate accrual, and absence of cross-user withdrawals. Test unsolicited donations separately.","Test unauthorized withdrawals, transfer attempts affecting another user's position, unauthorized rate changes and any administrative surplus recovery. Verify no call can confiscate principal or decrease earned points. Test emitted event fields against successful state transitions and ensure failures produce no effective events.","Verify all six named vectors, the fractional example, and read requirements against a concrete implementation. The optional rate-change vector is applicable only if a rate setter exists; otherwise verify immutability instead."],"unresolvedQuestions":["The requester has not selected the actual emission rate, its point unit, or whether the rate can change. This specification leaves R symbolic and defines acceptance for either rate mode.","The implementation must choose and disclose Q and safe operational bounds; suitability of the resulting rounding loss depends on actual stakes, durations and settlement frequency.","No staking implementation or deployed TEST token was supplied, so its token behavior, security properties, interfaces and on-chain deployment cannot be verified here."],"gates":{"specComplete":"pass","implementationVerified":"not_evaluated"}}
