@aephia/atlas-kit 0.8.0-next.27 → 0.8.0-next.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/claim-stakes/actions/index.d.ts +49 -0
- package/dist/claim-stakes/actions/index.d.ts.map +1 -1
- package/dist/claim-stakes/actions/index.js +181 -2
- package/dist/claim-stakes/actions/index.js.map +1 -1
- package/dist/identity/actions/daily-check-in.d.ts +57 -0
- package/dist/identity/actions/daily-check-in.d.ts.map +1 -0
- package/dist/identity/actions/daily-check-in.js +200 -0
- package/dist/identity/actions/daily-check-in.js.map +1 -0
- package/dist/identity/actions/index.d.ts +1 -0
- package/dist/identity/actions/index.d.ts.map +1 -1
- package/dist/identity/actions/index.js +1 -0
- package/dist/identity/actions/index.js.map +1 -1
- package/dist/internal/c4/discriminators.d.ts +2 -0
- package/dist/internal/c4/discriminators.d.ts.map +1 -1
- package/dist/internal/c4/discriminators.js +5 -1
- package/dist/internal/c4/discriminators.js.map +1 -1
- package/dist/internal/c4/game.d.ts +12 -0
- package/dist/internal/c4/game.d.ts.map +1 -1
- package/dist/internal/c4/game.js +17 -0
- package/dist/internal/c4/game.js.map +1 -1
- package/dist/internal/c4/runtime-bindings.d.ts +1 -1
- package/dist/internal/c4/runtime-bindings.d.ts.map +1 -1
- package/dist/internal/c4/runtime-bindings.js +1 -1
- package/dist/internal/c4/runtime-bindings.js.map +1 -1
- package/dist/internal/planning/authorization-adapter.d.ts +29 -0
- package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
- package/dist/internal/planning/authorization-adapter.js +43 -1
- package/dist/internal/planning/authorization-adapter.js.map +1 -1
- package/dist/internal/planning/currency-cache-guard.d.ts.map +1 -1
- package/dist/internal/planning/currency-cache-guard.js +2 -1
- package/dist/internal/planning/currency-cache-guard.js.map +1 -1
- package/dist/internal/planning/daily-check-in.d.ts +71 -0
- package/dist/internal/planning/daily-check-in.d.ts.map +1 -0
- package/dist/internal/planning/daily-check-in.js +201 -0
- package/dist/internal/planning/daily-check-in.js.map +1 -0
- package/dist/internal/planning/plan-guards.d.ts.map +1 -1
- package/dist/internal/planning/plan-guards.js +1 -0
- package/dist/internal/planning/plan-guards.js.map +1 -1
- package/dist/internal/planning/rent-catalog.d.ts.map +1 -1
- package/dist/internal/planning/rent-catalog.js +10 -1
- package/dist/internal/planning/rent-catalog.js.map +1 -1
- package/dist/internal/planning/runtime-guards.d.ts.map +1 -1
- package/dist/internal/planning/runtime-guards.js +11 -2
- package/dist/internal/planning/runtime-guards.js.map +1 -1
- package/dist/planning/execution.d.ts.map +1 -1
- package/dist/planning/execution.js +19 -0
- package/dist/planning/execution.js.map +1 -1
- package/dist/planning/index.d.ts +21 -0
- package/dist/planning/index.d.ts.map +1 -1
- package/dist/planning/index.js.map +1 -1
- package/dist/planning/plan-validation.d.ts.map +1 -1
- package/dist/planning/plan-validation.js +4 -0
- package/dist/planning/plan-validation.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ const systems = await getStarSystems(ctx);
|
|
|
81
81
|
| `@aephia/atlas-kit/fleets` | Fleet address discovery, snapshots, ships, composition, movement state, and relationships |
|
|
82
82
|
| `@aephia/atlas-kit/fleets/actions` | Inspectable Fleet movement, arrival-settlement, and wallet ship import planners |
|
|
83
83
|
| `@aephia/atlas-kit/identity` | Wallet, Profile, Character, progression, and research reads |
|
|
84
|
-
| `@aephia/atlas-kit/identity/actions` | Address-only Character registration for an existing Profile, with an explicit funder
|
|
84
|
+
| `@aephia/atlas-kit/identity/actions` | Address-only Character registration for an existing Profile, with an explicit funder, and a daily check-in |
|
|
85
85
|
| `@aephia/atlas-kit/loyalty` | Loyalty epochs, contributions, banks, and lifecycle |
|
|
86
86
|
| `@aephia/atlas-kit/loyalty/actions` | Address-only full-balance Loyalty ATLAS claim planning |
|
|
87
87
|
| `@aephia/atlas-kit/markets` | Local Market orders, maker state, and discovery |
|
|
@@ -254,6 +254,17 @@ export interface PlanExitClaimStakeFleetTransferOptions {
|
|
|
254
254
|
readonly atUnixSeconds: bigint;
|
|
255
255
|
readonly funder: Address;
|
|
256
256
|
}
|
|
257
|
+
/** Options for {@link planSettleClaimStakeProduction}. The `funder` is the
|
|
258
|
+
* only signer; any wallet may bring any Claim Stake's production up to date.
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* declare const funder: Address;
|
|
262
|
+
* const options: PlanSettleClaimStakeProductionOptions = { funder };
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export interface PlanSettleClaimStakeProductionOptions {
|
|
266
|
+
readonly funder: Address;
|
|
267
|
+
}
|
|
257
268
|
interface FleetSnapshot extends Omit<ResolvedFleetAccountData, 'ownerProfile'> {
|
|
258
269
|
readonly kind: 'fleet';
|
|
259
270
|
readonly address: Address;
|
|
@@ -620,4 +631,42 @@ export declare function planRecoverClaimStakeFleetTransfer(ctx: SageContext, fle
|
|
|
620
631
|
* ```
|
|
621
632
|
*/
|
|
622
633
|
export declare function planExitClaimStakeFleetTransfer(ctx: SageContext, fleet: FleetSnapshot, stake: ClaimStakeSnapshot, input: PlanExitClaimStakeFleetTransferOptions): Promise<Plan>;
|
|
634
|
+
/** Plans bringing one Claim Stake's production up to date.
|
|
635
|
+
*
|
|
636
|
+
* Production is permissionless: any wallet may tick any Claim Stake, so the
|
|
637
|
+
* Plan's only signer is the `funder`, which pays any growth of the stake's
|
|
638
|
+
* account. Rent the stake frees goes to its owner Profile. The game pays the
|
|
639
|
+
* stake's rent up to now, then produces from its last tick to now: each
|
|
640
|
+
* Building's processors turn their inputs into outputs at the stake's net
|
|
641
|
+
* rates, a processor that runs short of an input pauses, and output stops at
|
|
642
|
+
* the stake's storage, with Fuel limited to its separate fuel storage. The
|
|
643
|
+
* tick also records paid operational Building work and claim Mining work for
|
|
644
|
+
* a later {@link planSettleClaimStakeBuildingXp}.
|
|
645
|
+
*
|
|
646
|
+
* The planner refuses what the game would refuse: a stake in design, a
|
|
647
|
+
* Deactivated stake past its eviction grace, a stake its Planet does not
|
|
648
|
+
* register or has evicted, a Starbase Player from an earlier Starbase, and a
|
|
649
|
+
* stake whose rent balance does not cover the time up to now, which the game
|
|
650
|
+
* would deactivate instead. A Deactivated stake whose topped-up balance covers
|
|
651
|
+
* the time up to now is reactivated, then produces. It also refuses a stake
|
|
652
|
+
* still under construction or already up to date, which would produce
|
|
653
|
+
* nothing. The description projects the elapsed time, the approximate amounts
|
|
654
|
+
* at the stored net rates, storage, and the rent paid-through time; exact
|
|
655
|
+
* amounts, processor pauses and whether the Planet allows harvesting remain
|
|
656
|
+
* chain-authoritative.
|
|
657
|
+
*
|
|
658
|
+
* Requires Disabled rent and the current System generation. Bringing a large
|
|
659
|
+
* stake up to date can take more than the default 200,000 compute units, so
|
|
660
|
+
* simulate first and raise `computeUnitLimit` when assembling if needed.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```ts
|
|
664
|
+
* declare const ctx: SageContext;
|
|
665
|
+
* declare const stake: ClaimStakeSnapshot;
|
|
666
|
+
* declare const funder: Address;
|
|
667
|
+
* const plan = await planSettleClaimStakeProduction(ctx, stake, { funder });
|
|
668
|
+
* console.log(plan.describe());
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
671
|
+
export declare function planSettleClaimStakeProduction(ctx: SageContext, stake: ClaimStakeSnapshot, input: PlanSettleClaimStakeProductionOptions): Promise<Plan>;
|
|
623
672
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/claim-stakes/actions/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,OAAO,EAAoB,MAAM,aAAa,CAAC;AAExE,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA6CtD,OAAO,EA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GAmDG;AACH,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAqSf;AA8ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,kCAAkC,CACtD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,yCAAyC,GAC/C,OAAO,CAAC,IAAI,CAAC,CAyJf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,sCAAsC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAgNf;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,IAAI,CAAC,CA4Nf"}
|
|
@@ -28,10 +28,11 @@ import { requireProfileStarbasePlayer } from '../../internal/planning/starbase-p
|
|
|
28
28
|
import { requireGameAddress } from '../../internal/game-context.js';
|
|
29
29
|
import { structurePlacementFee } from '../../internal/planning/placement-fee.js';
|
|
30
30
|
import { cargoStorageUnits, cargoStorageUnitsFloor, } from '../../internal/cargo.js';
|
|
31
|
-
import { adaptCancelClaimStakeBuildingChangesInstruction, adaptClaimStakeBuildingChangesInstruction, adaptDeconstructClaimStakeInstruction, adaptExitClaimStakeFleetTransferInstruction, adaptFinalizeClaimStakeBuildingChangesInstruction, adaptPlaceClaimStakeInstruction, adaptRecoverClaimStakeFleetTransferInstruction, adaptSettleClaimStakeBuildingXpInstruction, adaptStartClaimStakeFleetTransferInstruction, adaptTopUpClaimStakeRentInstruction, readPlanAuthorization, } from '../../internal/planning/authorization-adapter.js';
|
|
31
|
+
import { adaptCancelClaimStakeBuildingChangesInstruction, adaptClaimStakeBuildingChangesInstruction, adaptDeconstructClaimStakeInstruction, adaptClaimStakeResourceProductionInstruction, adaptExitClaimStakeFleetTransferInstruction, adaptFinalizeClaimStakeBuildingChangesInstruction, adaptPlaceClaimStakeInstruction, adaptRecoverClaimStakeFleetTransferInstruction, adaptSettleClaimStakeBuildingXpInstruction, adaptStartClaimStakeFleetTransferInstruction, adaptTopUpClaimStakeRentInstruction, readPlanAuthorization, } from '../../internal/planning/authorization-adapter.js';
|
|
32
32
|
import { buildPlannerPlan } from '../../planning/plan-construction.js';
|
|
33
33
|
import { readFreshGameCargoDefinitions } from '../../registry/cargo.js';
|
|
34
|
-
import { listClaimStakeBuildingDefinitions, resolveCargo, } from '../../registry/index.js';
|
|
34
|
+
import { listClaimStakeBuildingDefinitions, resolveCargo, resolveClaimStakeDefinition, } from '../../registry/index.js';
|
|
35
|
+
import { CLOCK_ADDRESS, readClock, } from '../../internal/planning/faction-enrollment.js';
|
|
35
36
|
import { accountAbsentPrecondition, accountStatePrecondition, } from '../../internal/planning/account-state.js';
|
|
36
37
|
async function resolveClaimStakeXp(ctx, game, character) {
|
|
37
38
|
const xp = await resolveXpRuntime(ctx, {
|
|
@@ -267,6 +268,11 @@ function validateExitFleetTransferOptions(value) {
|
|
|
267
268
|
funder: address(options.funder, 'funder'),
|
|
268
269
|
};
|
|
269
270
|
}
|
|
271
|
+
function validateSettleProductionOptions(value) {
|
|
272
|
+
const options = record(value, 'options');
|
|
273
|
+
exactKeys(options, 'options', ['funder']);
|
|
274
|
+
return { funder: address(options.funder, 'funder') };
|
|
275
|
+
}
|
|
270
276
|
function requireAccount(account, accountAddress, message) {
|
|
271
277
|
return account ?? fail(message, accountAddress);
|
|
272
278
|
}
|
|
@@ -2305,4 +2311,177 @@ export async function planExitClaimStakeFleetTransfer(ctx, fleet, stake, input)
|
|
|
2305
2311
|
summary: description,
|
|
2306
2312
|
});
|
|
2307
2313
|
}
|
|
2314
|
+
/** The latest Unix second a JavaScript Date can represent. */
|
|
2315
|
+
const DATE_LIMIT_SECONDS = 8640000000000n;
|
|
2316
|
+
/** A Unix time as an ISO-8601 instant, or as Unix seconds beyond the range a
|
|
2317
|
+
* Date can represent, which a long rent balance can reach. */
|
|
2318
|
+
function instant(unixSeconds) {
|
|
2319
|
+
return unixSeconds > DATE_LIMIT_SECONDS || unixSeconds < -DATE_LIMIT_SECONDS
|
|
2320
|
+
? `Unix time ${String(unixSeconds)}`
|
|
2321
|
+
: new Date(Number(unixSeconds) * 1000).toISOString();
|
|
2322
|
+
}
|
|
2323
|
+
/** The legacy rent a Claim Stake pays per second, as a raw rate with 56
|
|
2324
|
+
* fractional bits: the Planet's base rate for the stake's tier at the
|
|
2325
|
+
* Starbase's current level, times the definition's rent multiplier. */
|
|
2326
|
+
function claimStakeRentRate(baseRaw, multiplierRaw) {
|
|
2327
|
+
// The base rate has 32 fractional bits and the multiplier 56.
|
|
2328
|
+
return (baseRaw * multiplierRaw) >> 32n;
|
|
2329
|
+
}
|
|
2330
|
+
/** Plans bringing one Claim Stake's production up to date.
|
|
2331
|
+
*
|
|
2332
|
+
* Production is permissionless: any wallet may tick any Claim Stake, so the
|
|
2333
|
+
* Plan's only signer is the `funder`, which pays any growth of the stake's
|
|
2334
|
+
* account. Rent the stake frees goes to its owner Profile. The game pays the
|
|
2335
|
+
* stake's rent up to now, then produces from its last tick to now: each
|
|
2336
|
+
* Building's processors turn their inputs into outputs at the stake's net
|
|
2337
|
+
* rates, a processor that runs short of an input pauses, and output stops at
|
|
2338
|
+
* the stake's storage, with Fuel limited to its separate fuel storage. The
|
|
2339
|
+
* tick also records paid operational Building work and claim Mining work for
|
|
2340
|
+
* a later {@link planSettleClaimStakeBuildingXp}.
|
|
2341
|
+
*
|
|
2342
|
+
* The planner refuses what the game would refuse: a stake in design, a
|
|
2343
|
+
* Deactivated stake past its eviction grace, a stake its Planet does not
|
|
2344
|
+
* register or has evicted, a Starbase Player from an earlier Starbase, and a
|
|
2345
|
+
* stake whose rent balance does not cover the time up to now, which the game
|
|
2346
|
+
* would deactivate instead. A Deactivated stake whose topped-up balance covers
|
|
2347
|
+
* the time up to now is reactivated, then produces. It also refuses a stake
|
|
2348
|
+
* still under construction or already up to date, which would produce
|
|
2349
|
+
* nothing. The description projects the elapsed time, the approximate amounts
|
|
2350
|
+
* at the stored net rates, storage, and the rent paid-through time; exact
|
|
2351
|
+
* amounts, processor pauses and whether the Planet allows harvesting remain
|
|
2352
|
+
* chain-authoritative.
|
|
2353
|
+
*
|
|
2354
|
+
* Requires Disabled rent and the current System generation. Bringing a large
|
|
2355
|
+
* stake up to date can take more than the default 200,000 compute units, so
|
|
2356
|
+
* simulate first and raise `computeUnitLimit` when assembling if needed.
|
|
2357
|
+
*
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```ts
|
|
2360
|
+
* declare const ctx: SageContext;
|
|
2361
|
+
* declare const stake: ClaimStakeSnapshot;
|
|
2362
|
+
* declare const funder: Address;
|
|
2363
|
+
* const plan = await planSettleClaimStakeProduction(ctx, stake, { funder });
|
|
2364
|
+
* console.log(plan.describe());
|
|
2365
|
+
* ```
|
|
2366
|
+
*/
|
|
2367
|
+
export async function planSettleClaimStakeProduction(ctx, stake, input) {
|
|
2368
|
+
const options = validateSettleProductionOptions(input);
|
|
2369
|
+
const game = requireGameAddress(ctx);
|
|
2370
|
+
const profile = stake.ownerProfile.address;
|
|
2371
|
+
if (stake.state.kind === 'design') {
|
|
2372
|
+
fail(`Claim Stake ${stake.address} is in design, and the game produces only for a built stake. Finalize its building changes, refresh it, and retry the production tick.`, stake.address);
|
|
2373
|
+
}
|
|
2374
|
+
const character = await requireOwnedStake(ctx.programs, stake, game, profile);
|
|
2375
|
+
const currencyCache = await claimStakeCurrencyCache(ctx.programs, game);
|
|
2376
|
+
const action = 'the Claim Stake production tick';
|
|
2377
|
+
const [{ bodyAccount, currentBody, currentStake, extraAccounts: [clockCandidate], stakeAccount, }, rent, definition, xp,] = await Promise.all([
|
|
2378
|
+
readOwnedStake(ctx, stake, action, [CLOCK_ADDRESS]),
|
|
2379
|
+
requireDisabledStakeRent(ctx, game, stake.address, action),
|
|
2380
|
+
resolveClaimStakeDefinition(ctx, stake.claimStakeDefinitionId),
|
|
2381
|
+
resolveClaimStakeXp(ctx, game),
|
|
2382
|
+
]);
|
|
2383
|
+
if (!sameOwnedStake(currentStake, stake, game, profile) ||
|
|
2384
|
+
!sameStakeState(currentStake.state, stake.state)) {
|
|
2385
|
+
fail(`Claim Stake ${stake.address} changed or does not match its loaded ownership, Body, definitions, buildings, lifecycle state, or System generation. Refresh it and retry ${action}.`, stake.address);
|
|
2386
|
+
}
|
|
2387
|
+
const now = readClock(requireAccount(clockCandidate, CLOCK_ADDRESS, 'The Clock sysvar is missing. Refresh chain time and retry the production tick.'));
|
|
2388
|
+
const planet = await requireStakePlanet(ctx.programs, currentBody, stake, game, action);
|
|
2389
|
+
const { system } = planet;
|
|
2390
|
+
const { currentPlayer, currentSystem, extraAccounts: [cacheCandidate], player, playerAccount, starbase, systemAccount, } = await readStakeStarbase(ctx, stake, game, system, character, profile, action, [currencyCache]);
|
|
2391
|
+
requireStakeRegistered(planet.details.claimedPlots, stake, starbase.level, action);
|
|
2392
|
+
if (currentPlayer.sequenceId !== currentSystem.sequenceId)
|
|
2393
|
+
fail(`Starbase Player ${player} was registered at an earlier Starbase in Star System ${system}, which the game treats as destroyed. The owner must register at the current Starbase before ${action}.`, player);
|
|
2394
|
+
const cacheGuard = await requireCurrencyCache(ctx.programs, cacheCandidate, currencyCache, game, action, 'planSettleClaimStakeProduction');
|
|
2395
|
+
let reactivation = '';
|
|
2396
|
+
if (currentStake.state.kind === 'deactivated') {
|
|
2397
|
+
const graceEnds = currentStake.state.deactivatedAtUnixSeconds +
|
|
2398
|
+
definition.evictionGracePeriodSeconds;
|
|
2399
|
+
if (now > graceEnds)
|
|
2400
|
+
fail(`Claim Stake ${stake.address} was deactivated for unpaid rent and its eviction grace ended at ${instant(graceEnds)}, so the game no longer produces for it. It can only be evicted or respawned.`, stake.address);
|
|
2401
|
+
reactivation = ` The stake is Deactivated within its eviction grace, which ends at ${instant(graceEnds)}; the game reactivates it once its rent covers the time up to now, then produces.`;
|
|
2402
|
+
}
|
|
2403
|
+
const rate = claimStakeRentRate(planet.details.baseClaimStakeRentRate[LEVEL_INDEX[starbase.level]][TIER_INDEX[definition.tier]].raw, definition.rentMultiplier.raw);
|
|
2404
|
+
const paidThrough = rate === 0n
|
|
2405
|
+
? undefined
|
|
2406
|
+
: currentStake.lastRentAtUnixSeconds +
|
|
2407
|
+
(currentStake.rentBalanceRaw << 56n) / rate;
|
|
2408
|
+
if (paidThrough !== undefined && paidThrough < now)
|
|
2409
|
+
fail(`Claim Stake ${stake.address}'s rent balance pays only through about ${instant(paidThrough)}, before chain time ${instant(now)}, so the game would deactivate the stake instead of producing. Top up its rent, refresh, and retry.`, stake.address);
|
|
2410
|
+
const constructionEnds = currentStake.constructionProgressAtUnixSeconds +
|
|
2411
|
+
currentStake.constructionRemainingSeconds;
|
|
2412
|
+
if (currentStake.constructionRemainingSeconds > 0n && constructionEnds > now)
|
|
2413
|
+
fail(`Claim Stake ${stake.address} is under construction until about ${instant(constructionEnds)} and produces nothing until then. Wait for construction to finish and retry ${action}.`, stake.address);
|
|
2414
|
+
const { production } = currentStake;
|
|
2415
|
+
const elapsed = now - production.lastTickAtUnixSeconds;
|
|
2416
|
+
if (elapsed <= 0n)
|
|
2417
|
+
fail(`Claim Stake ${stake.address}'s production is already up to date at chain time ${instant(now)}. Wait and retry ${action}.`, stake.address);
|
|
2418
|
+
const flows = await Promise.all(production.netResources.map(async ({ cargoId, ratePerSecond }) => {
|
|
2419
|
+
const { name } = await resolveCargo(ctx, cargoId);
|
|
2420
|
+
const amount = Math.round(Math.abs(ratePerSecond) * Number(elapsed));
|
|
2421
|
+
const stored = cargoAmount(production.cargoPod.amounts, cargoId);
|
|
2422
|
+
// Seconds of consumption the stored input covers; Infinity for outputs.
|
|
2423
|
+
const covers = ratePerSecond < 0
|
|
2424
|
+
? Math.floor(Number(stored) / -ratePerSecond)
|
|
2425
|
+
: Number.POSITIVE_INFINITY;
|
|
2426
|
+
return { amount, covers, name, produced: ratePerSecond > 0, stored };
|
|
2427
|
+
}));
|
|
2428
|
+
const short = flows
|
|
2429
|
+
.filter((flow) => flow.covers < Number(elapsed))
|
|
2430
|
+
.map(({ covers, name, stored }) => stored === 0n
|
|
2431
|
+
? `the stake holds no ${name}`
|
|
2432
|
+
: covers === 0
|
|
2433
|
+
? `stored ${name} lasts less than one second`
|
|
2434
|
+
: `stored ${name} covers only about ${String(covers)} of those seconds`);
|
|
2435
|
+
const shortage = short.length === 0
|
|
2436
|
+
? ''
|
|
2437
|
+
: ` Warning: ${short.join('; ')}. Processors that need an exhausted input pause, which can stop the stake's output entirely, so expect far less than these amounts.`;
|
|
2438
|
+
const list = (produced) => flows
|
|
2439
|
+
.filter((flow) => flow.produced === produced && flow.amount > 0)
|
|
2440
|
+
.map(({ amount, name }) => `${String(amount)} ${name}`)
|
|
2441
|
+
.join(', ');
|
|
2442
|
+
const made = list(true);
|
|
2443
|
+
const used = list(false);
|
|
2444
|
+
const rates = made === '' && used === ''
|
|
2445
|
+
? 'Its stored net rates produce and consume nothing.'
|
|
2446
|
+
: `At its stored net rates that is about ${[
|
|
2447
|
+
...(made === '' ? [] : [`${made} produced`]),
|
|
2448
|
+
...(used === '' ? [] : [`${used} consumed`]),
|
|
2449
|
+
].join(' and ')}, before storage limits and processor pauses.${shortage}`;
|
|
2450
|
+
const rentPaid = paidThrough === undefined
|
|
2451
|
+
? 'The stake pays no rent at the Starbase’s current level.'
|
|
2452
|
+
: `Its rent balance pays through about ${instant(paidThrough)}.`;
|
|
2453
|
+
const description = `Bring Claim Stake ${stake.address}'s production up to date: ${String(elapsed)} seconds since its last tick at ${instant(production.lastTickAtUnixSeconds)}. ${rates} Storage holds ${String(production.cargoPod.storageCost)} of ${String(production.resourceCapacityRaw)} capacity units. ${rentPaid}${reactivation} Funder ${options.funder} signs and pays any growth of the stake's account; rent the stake frees goes to Profile ${profile}. Exact amounts, processor pauses and whether the Planet allows harvesting remain chain-authoritative.`;
|
|
2454
|
+
return buildPlannerPlan(ctx.programs, {
|
|
2455
|
+
kind: 'claim-stakes.settle-production',
|
|
2456
|
+
preconditions: [
|
|
2457
|
+
xp.guard,
|
|
2458
|
+
...(await Promise.all([
|
|
2459
|
+
accountStatePrecondition(stakeAccount, `Claim Stake ${stake.address} retains its owner, buildings, rent, production, lifecycle state, Body, and System generation.`),
|
|
2460
|
+
planetPrecondition(bodyAccount, system),
|
|
2461
|
+
systemPrecondition(systemAccount, currentSystem.name),
|
|
2462
|
+
playerPrecondition(playerAccount, player),
|
|
2463
|
+
])),
|
|
2464
|
+
cacheGuard,
|
|
2465
|
+
...rent.guards,
|
|
2466
|
+
],
|
|
2467
|
+
steps: [
|
|
2468
|
+
{
|
|
2469
|
+
describes: description,
|
|
2470
|
+
instruction: adaptClaimStakeResourceProductionInstruction(ctx.programs, {
|
|
2471
|
+
celestialBody: stake.body.address,
|
|
2472
|
+
claimStakeInstance: stake.address,
|
|
2473
|
+
currencyCache,
|
|
2474
|
+
funder: options.funder,
|
|
2475
|
+
game,
|
|
2476
|
+
profile,
|
|
2477
|
+
...rent.accounts,
|
|
2478
|
+
systemAndStarbasePlayerStarbasePlayer: player,
|
|
2479
|
+
systemAndStarbasePlayerSystem: system,
|
|
2480
|
+
}),
|
|
2481
|
+
signers: [options.funder],
|
|
2482
|
+
},
|
|
2483
|
+
],
|
|
2484
|
+
summary: description,
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2308
2487
|
//# sourceMappingURL=index.js.map
|