@ouronet/ouronet-core 4.5.1 → 4.6.0
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/CHANGELOG.md +72 -0
- package/README.md +4 -0
- package/dist/interactions/activateFunctions.js +2 -2
- package/dist/interactions/addLiquidityFunctions.js +2 -2
- package/dist/interactions/coilFunctions.js +2 -1
- package/dist/interactions/crossChainFunctions.d.ts +18 -0
- package/dist/interactions/crossChainFunctions.js +17 -40
- package/dist/interactions/dexSwapPairExecuteFunctions.js +5 -5
- package/dist/interactions/dexSwapPairSmartSwapFunctions.js +3 -3
- package/dist/interactions/guardFunctions.js +10 -49
- package/dist/interactions/kpayFunctions.js +2 -2
- package/dist/interactions/ouroCoilFunctions.js +3 -3
- package/dist/interactions/ouroMovieBoosterFunctions.js +4 -4
- package/dist/interactions/ouroRotateFunctions.js +10 -49
- package/dist/interactions/ouroSubCompressFunctions.js +3 -3
- package/dist/interactions/ouroTransferFunctions.js +2 -2
- package/dist/interactions/ouroUrStoaFunctions.js +2 -2
- package/dist/interactions/ouroWrapFunctions.js +4 -4
- package/dist/interactions/pensionFunctions.js +3 -3
- package/dist/interactions/urStoaFunctions.js +6 -6
- package/dist/interactions/wrapFunctions.js +4 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,78 @@ All notable changes to `@ouronet/ouronet-core`.
|
|
|
4
4
|
|
|
5
5
|
This package is the historical continuation of `@ouronet/ouronet-core` v0.x–v3.3.8. v4.0.0 split it into a two-package npm workspace under `StoaChain/stoa-js` — chain-generic infrastructure moved out into [`@stoachain/stoa-core`](https://www.npmjs.com/package/@stoachain/stoa-core), this package retained the Ouronet-specific business logic. The `4.0.0` heading below is the first release after the split.
|
|
6
6
|
|
|
7
|
+
## 4.6.0 — 2026-09-07
|
|
8
|
+
|
|
9
|
+
**MINOR — chain peers re-pinned to 4.4.0; every transaction in the package now prices against the live Yin floor.**
|
|
10
|
+
|
|
11
|
+
### Chain peers
|
|
12
|
+
|
|
13
|
+
`@stoachain/stoa-core` and `@stoachain/kadena-stoic-legacy` move `4.3.7` → **`4.4.0`** (exact,
|
|
14
|
+
as always — the root `devDependencies` move with them). stoa-core 4.4.0 is what makes the rest
|
|
15
|
+
of this release possible: it ships the **canonical Yin Engine** at `@stoachain/stoa-core/gas`
|
|
16
|
+
(`stoaGasMeta`, `minGasPriceAnu`, `anuToStoaNumber`, and the four constants).
|
|
17
|
+
|
|
18
|
+
### The bug, in full
|
|
19
|
+
|
|
20
|
+
The Yin Engine is StoaChain's live minimum gas price: 10,000 ANU at genesis
|
|
21
|
+
(2026-02-23T18:00:00Z), +1 ANU every 3 hours, capped at 400,000 ANU. A transaction priced below
|
|
22
|
+
the floor as of its own `creationTime` is rejected by chainweb-node.
|
|
23
|
+
|
|
24
|
+
Every `setMeta` call in this package set `creationTime` and nothing else, so the vendored client
|
|
25
|
+
supplied its own `gasPrice` default of `1.0e-8` — which is *exactly* the genesis floor. From the
|
|
26
|
+
floor's first tick onward, **every transaction this package built was underpriced**. Paying via
|
|
27
|
+
the Ouronet Gas Station is no exemption: `DALOS.GAS_PAYER` decides who pays, not how little, and
|
|
28
|
+
the chain-wide minimum-price rule is evaluated before the payer guard runs.
|
|
29
|
+
|
|
30
|
+
4.5.0 fixed the four cross-chain sites; 4.5.1 fixed the two rotation executors. This release
|
|
31
|
+
fixes the remaining **32 sites across 15 files** and unifies all 38 on one implementation.
|
|
32
|
+
(4.5.1's changelog said "17 other files" — the accurate count is 15 files / 32 sites.)
|
|
33
|
+
|
|
34
|
+
Newly priced: `activateFunctions`, `addLiquidityFunctions`, `coilFunctions`,
|
|
35
|
+
`dexSwapPairExecuteFunctions`, `dexSwapPairSmartSwapFunctions`, `kpayFunctions`,
|
|
36
|
+
`ouroCoilFunctions`, `ouroMovieBoosterFunctions`, `ouroSubCompressFunctions`,
|
|
37
|
+
`ouroTransferFunctions`, `ouroUrStoaFunctions`, `ouroWrapFunctions`, `pensionFunctions`,
|
|
38
|
+
`urStoaFunctions`, `wrapFunctions`.
|
|
39
|
+
|
|
40
|
+
### One implementation, not four
|
|
41
|
+
|
|
42
|
+
`crossChainFunctions.ts` (4.5.0), `guardFunctions.ts` and `ouroRotateFunctions.ts` (4.5.1) each
|
|
43
|
+
carried a **local copy** of the formula, written before stoa-core had it. All three copies are
|
|
44
|
+
deleted; every site now calls the canonical helper. The package contains no local
|
|
45
|
+
re-implementation of the Yin formula, and `v4-6-0-gas-price-invariant.test.ts` fails if one
|
|
46
|
+
reappears.
|
|
47
|
+
|
|
48
|
+
### The call is `stoaGasMeta(safeCreationTime())`, deliberately
|
|
49
|
+
|
|
50
|
+
The canonical `stoaGasMeta()` defaults its clock read to `Math.floor(Date.now() / 1000)`. This
|
|
51
|
+
package has stamped `safeCreationTime()` — the same value minus 30 s — since v3.2.3, to stop a
|
|
52
|
+
client clock running slightly ahead of node time from causing sporadic submit failures (audit
|
|
53
|
+
finding F-BUG-002). Passing that value in explicitly keeps the skew **and** keeps the invariant
|
|
54
|
+
that matters: the price is computed from the exact `creationTime` the command carries, from one
|
|
55
|
+
clock read, so a tick crossing between two reads can never underprice the transaction. Calling
|
|
56
|
+
the bare `stoaGasMeta()` here would silently drop the skew — don't.
|
|
57
|
+
|
|
58
|
+
### Verification
|
|
59
|
+
|
|
60
|
+
Two new test files, **43 specs**:
|
|
61
|
+
|
|
62
|
+
- `v4-6-0-executor-gas-price.test.ts` — behavioural. Drives one real executor per fixed file
|
|
63
|
+
(17 in total, including the two rotations) through the mocked network seam plus all four pure
|
|
64
|
+
cross-chain builders, pins the clock 1,157 ticks past genesis, and asserts the command that
|
|
65
|
+
would reach chainweb carries `gasPrice = 0.000000011157`, above the `1.0e-8` default and equal
|
|
66
|
+
to the floor recomputed from the `creationTime` the command actually ships.
|
|
67
|
+
- `v4-6-0-gas-price-invariant.test.ts` — structural. Brace-matches **every** `.setMeta({...})`
|
|
68
|
+
object literal in `src/` (38 of them, including branches the behavioural sample does not drive
|
|
69
|
+
and any file added later) and requires the `stoaGasMeta(safeCreationTime())` spread, no
|
|
70
|
+
hand-written `gasPrice`/`creationTime` key, the canonical imports, and no local copy of the
|
|
71
|
+
formula. This one exists because the failure mode is silent — an omitted `gasPrice` builds and
|
|
72
|
+
signs fine and only chainweb rejects it.
|
|
73
|
+
|
|
74
|
+
Both were confirmed non-vacuous: reverting a single site to the old form fails four specs across
|
|
75
|
+
the two files.
|
|
76
|
+
|
|
77
|
+
Non-breaking. No exported signatures changed. **845 specs pass** (was 800).
|
|
78
|
+
|
|
7
79
|
## 4.5.1 — 2026-09-07
|
|
8
80
|
|
|
9
81
|
**PATCH — the two rotation executors were submitting underpriced transactions.**
|
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@ Chain-generic infrastructure (signing, wallet, crypto, network failover, gas, gu
|
|
|
23
23
|
|
|
24
24
|
## Status
|
|
25
25
|
|
|
26
|
+
**`4.6.0` on public npmjs** — **MINOR (chain peers re-pinned to 4.4.0; every transaction in the package now prices against the live Yin floor).** Released 2026-09-07. `@stoachain/stoa-core` and `@stoachain/kadena-stoic-legacy` move `4.3.7` → `4.4.0` (exact, as always); stoa-core 4.4.0 ships the canonical Yin Engine at `@stoachain/stoa-core/gas`. Every `setMeta` in this package set `creationTime` alone, so the vendored client filled in `gasPrice: 1.0e-8` — exactly the Yin genesis floor — leaving every transaction underpriced from the floor's first tick onward (Gas-Station payment is no exemption: `DALOS.GAS_PAYER` decides *who* pays, not *how little*). 4.5.0 fixed the four cross-chain sites and 4.5.1 the two rotation executors; this release fixes the remaining **32 sites across 15 files** and unifies all 38 on the canonical helper, deleting the three local copies of the formula that 4.5.0/4.5.1 had to carry. Call form is `stoaGasMeta(safeCreationTime())` — passing the clock read in explicitly preserves this package's -30s skew (F-BUG-002) while keeping the price derived from the exact `creationTime` the command ships. Verified by 43 new specs in two files: a behavioural one driving a real executor per fixed file plus all four cross-chain builders against a pinned clock, and a structural one that brace-matches every `setMeta` object literal in `src/` so a future omission fails CI. Non-breaking — no exported signatures changed. **845 specs pass.**
|
|
27
|
+
|
|
26
28
|
**`4.5.1` on public npmjs** — **PATCH (the two rotation executors were submitting underpriced transactions).** Released 2026-09-07. `guardFunctions.rotateGuard` and `ouroRotateFunctions.rotateKadenaPaymentKey` set `creationTime` but never set `gasPrice`, so the vendored client stamped its `1.0e-8` default — exactly the Yin Engine's *genesis* floor of 10,000 ANU. Since the floor rises 1 ANU every 3 hours, both rotations were built below the chain-wide minimum price and rejected as underpriced from the floor's first tick onward. Gas-Station payment is no exemption: `DALOS.GAS_PAYER` decides *who* pays, not *how little*, and the minimum-price rule runs before the payer guard. Same defect 4.5.0 fixed in `crossChainFunctions.ts`; these two files were not part of that change. Both `setMeta` calls now spread the same `stoaGasMeta()` helper — `{ creationTime, gasPrice }` from a single clock read, with a padding-built (never float-divided) ANU → STOA conversion. New `tests/v4-5-1-rotation-gas-price.test.ts` locks it with 12 specs, 8 of which fail against the pre-fix source. Note for auditors: 17 other `interactions/*` files call `setMeta` without a `gasPrice` and remain underpriced by the same mechanism — out of scope here. Non-breaking — no exported signatures changed. **800 specs pass.**
|
|
27
29
|
|
|
28
30
|
**`4.5.0` on public npmjs** — **MINOR (cross-chain gas payer switched to `stoa-xchain-gas`; live Yin-Engine gas pricing).** Released 2026-09-07. `crossChainFunctions.ts`'s non-chain-0 gas payer moves off the legacy `kadena-xchain-gas` account (a static `gasPrice <= 0.00000001` / `gasLimit <= 850` guard) onto StoaChain's own `stoa-xchain-gas` account, whose guard (`pact/genesis/stoa/stoa-genesis-5.pact`) requires `gasPrice <= UC_MinimumGasPriceANU()` — a *live floor*, not a fixed ceiling. All four `gasPrice` call sites in this file (the legacy `buildCrossChainTransfer`, both `buildCTransferAcross` branches — including the chain-0 `DALOS.GAS_PAYER` path, previously on the static `GAS_PRICE_MIN_ANU` — and `buildContinuationTransaction`'s default payer) now derive `{ creationTime, gasPrice }` from a local Yin-Engine helper instead of a hardcoded price. That helper is a temporary duplicate of OuronetUI's `src/lib/gas-price.ts` — it belongs in `@stoachain/stoa-core/gas` once that package ships the same formula (it currently still exports only the static `GAS_PRICE_MIN_ANU = 10_000`); consolidate then. Verified against a live StoaChain node: both the initial `C_TransferAcross` (chain-0, `DALOS.GAS_PAYER`) and the `stoa-xchain-gas`-paid continuation landed successfully at 11,565 ANU/gas. Non-breaking — no exported signatures changed, only the default `gasPayerAccount` value and the internal price derivation. **787 specs pass.**
|
|
@@ -49,6 +51,8 @@ Chain-generic infrastructure (signing, wallet, crypto, network failover, gas, gu
|
|
|
49
51
|
|
|
50
52
|
**`4.2.0` on public npmjs** — **MINOR (atomic with `@stoachain/stoa-core@4.2.0` + `@stoachain/kadena-stoic-legacy@4.2.0`).** Released 2026-05-09. Closes 6 audit findings: **F-ARCH-001** (Phase 1 dex god-file split — ~10 entity-oriented files + thin re-export shim), **F-ARCH-002** (Phase 2 ouro god-file split + chain/UI surgical separation — ~11 entity-oriented files + thin re-export shim), **F-ARCH-003** (Phase 3 parameterized liquidity executor — 5 thin wrappers + 1 internal `executeLiquidityOp`, LOC reduction ~600 → ~200), **F-API-002** (Phase 4 — 12 functions honor declared `Promise<T | null>` contract, return null on RPC failure instead of rethrowing), **F-API-018** (Phase 5 readonly sweep — ~50 public-type fields in `codex/types.ts` and all `*Params` interfaces), **F-TEST-006** (Phase 7 — +127 specs across 6 modules: `infoOneFunctions`, `coilFunctions`, `kpayFunctions`, `pensionFunctions`, `activateFunctions`, `guardFunctions`). NEW deliverable: [`INTEGRATION-GUIDE.md`](https://github.com/StoaChain/stoa-js/blob/main/INTEGRATION-GUIDE.md) at repo root — comprehensive cold-start consumer onboarding doc, 13 sections, full v4.0 → v4.1 → v4.2 architectural arc. 8 new `v4-2-0-*.test.ts` regression-lock files. Test count: **710 specs pass** (was ~330 in v4.1.1). Cross-reference: see [`MIGRATION-v4.2.md`](https://github.com/StoaChain/stoa-js/blob/main/MIGRATION-v4.2.md) at the monorepo root.
|
|
51
53
|
|
|
54
|
+
**v4.6.0** — chain peers re-pinned to 4.4.0 and live Yin-Engine pricing extended to the whole package. Released 2026-09-07. The remaining 32 `setMeta` sites across 15 `interactions/*` files were building transactions at the client's `1.0e-8` genesis-floor default; all 38 sites now spread the canonical `stoaGasMeta` from `@stoachain/stoa-core/gas`, and the three local copies of the formula are gone. No signature changes. **845 specs pass.**
|
|
55
|
+
|
|
52
56
|
**v4.5.1** — live Yin-Engine gas pricing for the two rotation executors (`rotateGuard`, `rotateKadenaPaymentKey`). Released 2026-09-07. Both omitted `gasPrice` entirely and inherited the client's `1.0e-8` genesis-floor default, so every rotation submitted after the floor's first tick was rejected as underpriced. No signature changes. **800 specs pass.**
|
|
53
57
|
|
|
54
58
|
**v4.5.0** — cross-chain gas payer switched to `stoa-xchain-gas` with live Yin-Engine pricing (replaces the legacy `kadena-xchain-gas` static ceiling). Released 2026-09-07. All four `gasPrice` sites in `crossChainFunctions.ts` now derive price from the current Yin floor instead of a hardcoded value; verified landing on a live StoaChain node at 11,565 ANU/gas. No signature changes. **787 specs pass.**
|
|
@@ -7,7 +7,7 @@ import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
|
7
7
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
8
8
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
9
9
|
import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/signing";
|
|
10
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
10
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
11
11
|
import { createSimulationError, logDetailedError } from "@stoachain/stoa-core/errors";
|
|
12
12
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
13
13
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
@@ -105,7 +105,7 @@ export async function executeDeployStandardAccount(params) {
|
|
|
105
105
|
.addData("ks", { keys: guardKeys, pred: guardPred })
|
|
106
106
|
.setMeta({
|
|
107
107
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
108
|
-
|
|
108
|
+
...stoaGasMeta(safeCreationTime()),
|
|
109
109
|
chainId: KADENA_CHAIN_ID,
|
|
110
110
|
gasLimit: effectiveGasLimit,
|
|
111
111
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
1
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
2
2
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
3
3
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
4
4
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
@@ -166,7 +166,7 @@ async function executeLiquidityOp(opts) {
|
|
|
166
166
|
})
|
|
167
167
|
.setMeta({
|
|
168
168
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
169
|
-
|
|
169
|
+
...stoaGasMeta(safeCreationTime()),
|
|
170
170
|
chainId: KADENA_CHAIN_ID,
|
|
171
171
|
gasLimit: gasLimitOverride ?? defaultGasLimit,
|
|
172
172
|
})
|
|
@@ -3,6 +3,7 @@ import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
|
3
3
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
4
4
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
5
5
|
import { formatDecimalForPact, safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
6
|
+
import { stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
7
|
import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/signing";
|
|
7
8
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
8
9
|
const coilPatternCache = new Map();
|
|
@@ -136,7 +137,7 @@ export async function coilTokensGeneric(ouroAccount, kadenaAccount, guard, targe
|
|
|
136
137
|
})
|
|
137
138
|
.setMeta({
|
|
138
139
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
139
|
-
|
|
140
|
+
...stoaGasMeta(safeCreationTime()),
|
|
140
141
|
chainId: KADENA_CHAIN_ID,
|
|
141
142
|
gasLimit: gasLimitOverride || gasLimit,
|
|
142
143
|
})
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { ITransactionDescriptor } from "@stoachain/kadena-stoic-legacy/client";
|
|
2
|
+
/**
|
|
3
|
+
* Gas pricing note — the Yin Engine now lives in `@stoachain/stoa-core/gas`.
|
|
4
|
+
*
|
|
5
|
+
* `stoaGasMeta(creationTime)` returns `{ creationTime, gasPrice }` from a
|
|
6
|
+
* single clock read: the price is the live minimum floor evaluated at exactly
|
|
7
|
+
* the `creationTime` the command will carry. The floor starts at 10,000 ANU at
|
|
8
|
+
* genesis (2026-02-23T18:00:00Z) and rises 1 ANU every 3 hours, capped at
|
|
9
|
+
* 400,000 ANU — source of truth `UC_MinimumGasPriceANU` in
|
|
10
|
+
* `pact/stoa-coin/new-coin.pact`. v4.5.0 shipped a local copy of that formula
|
|
11
|
+
* here because stoa-core still only had the static `GAS_PRICE_MIN_ANU`; 4.6.0
|
|
12
|
+
* deletes the copy in favour of the canonical implementation.
|
|
13
|
+
*
|
|
14
|
+
* `stoa-xchain-gas`'s own guard (`pact/genesis/stoa/stoa-genesis-5.pact`)
|
|
15
|
+
* requires `gasPrice <= UC_MinimumGasPriceANU()` (an upper bound, not a
|
|
16
|
+
* floor) — combined with the chain-wide "must be >= the floor" rule, the
|
|
17
|
+
* only value that satisfies both is the floor itself. Never overpay this
|
|
18
|
+
* account; it pays minimum-priced redemptions only.
|
|
19
|
+
*/
|
|
2
20
|
/**
|
|
3
21
|
* Get KDA balance for an account on a specific chain.
|
|
4
22
|
* exists=false means the account row does not exist on that chain (not just zero balance).
|
|
@@ -3,19 +3,18 @@ import { getFailoverClient, withFailover } from "@stoachain/stoa-core/network";
|
|
|
3
3
|
import { KADENA_NETWORK, getPactUrl, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NAMESPACE } from "../constants/index.js";
|
|
4
4
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
5
5
|
import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
|
|
6
|
+
import { stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
7
|
/**
|
|
7
|
-
* Yin Engine
|
|
8
|
+
* Gas pricing note — the Yin Engine now lives in `@stoachain/stoa-core/gas`.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `pact/stoa-coin/new-coin.pact` (evaluated against `(at "block-time"
|
|
18
|
-
* (chain-data))` on-chain — creationTime is a close client-side proxy for it).
|
|
10
|
+
* `stoaGasMeta(creationTime)` returns `{ creationTime, gasPrice }` from a
|
|
11
|
+
* single clock read: the price is the live minimum floor evaluated at exactly
|
|
12
|
+
* the `creationTime` the command will carry. The floor starts at 10,000 ANU at
|
|
13
|
+
* genesis (2026-02-23T18:00:00Z) and rises 1 ANU every 3 hours, capped at
|
|
14
|
+
* 400,000 ANU — source of truth `UC_MinimumGasPriceANU` in
|
|
15
|
+
* `pact/stoa-coin/new-coin.pact`. v4.5.0 shipped a local copy of that formula
|
|
16
|
+
* here because stoa-core still only had the static `GAS_PRICE_MIN_ANU`; 4.6.0
|
|
17
|
+
* deletes the copy in favour of the canonical implementation.
|
|
19
18
|
*
|
|
20
19
|
* `stoa-xchain-gas`'s own guard (`pact/genesis/stoa/stoa-genesis-5.pact`)
|
|
21
20
|
* requires `gasPrice <= UC_MinimumGasPriceANU()` (an upper bound, not a
|
|
@@ -23,27 +22,6 @@ import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pac
|
|
|
23
22
|
* only value that satisfies both is the floor itself. Never overpay this
|
|
24
23
|
* account; it pays minimum-priced redemptions only.
|
|
25
24
|
*/
|
|
26
|
-
const YIN_GENESIS_TIME_S = 1771869600; // 2026-02-23T18:00:00Z — tick 0
|
|
27
|
-
const YIN_GENESIS_MIN_GAS_ANU = 10000;
|
|
28
|
-
const YIN_MAX_GAS_ANU = 400000;
|
|
29
|
-
const YIN_GAS_PRICE_INTERVAL_S = 10800; // 3 h per tick
|
|
30
|
-
function minGasPriceAnu(creationTimeS) {
|
|
31
|
-
const elapsed = creationTimeS - YIN_GENESIS_TIME_S;
|
|
32
|
-
const ticks = elapsed <= 0 ? 0 : Math.floor(elapsed / YIN_GAS_PRICE_INTERVAL_S);
|
|
33
|
-
return Math.min(YIN_GENESIS_MIN_GAS_ANU + ticks, YIN_MAX_GAS_ANU);
|
|
34
|
-
}
|
|
35
|
-
/** Built by string padding, never float division — avoids exponential notation / precision loss. */
|
|
36
|
-
function anuToStoaNumber(anu) {
|
|
37
|
-
return Number("0." + String(anu).padStart(12, "0"));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* One clock read: the `creationTime` to stamp and the `gasPrice` derived
|
|
41
|
-
* FROM THAT EXACT VALUE, so the two can never disagree.
|
|
42
|
-
*/
|
|
43
|
-
function stoaGasMeta() {
|
|
44
|
-
const creationTime = safeCreationTime();
|
|
45
|
-
return { creationTime, gasPrice: anuToStoaNumber(minGasPriceAnu(creationTime)) };
|
|
46
|
-
}
|
|
47
25
|
/**
|
|
48
26
|
* Get KDA balance for an account on a specific chain.
|
|
49
27
|
* exists=false means the account row does not exist on that chain (not just zero balance).
|
|
@@ -116,13 +94,12 @@ export function buildCrossChainTransfer(params) {
|
|
|
116
94
|
// `@kadena/client` falls back to raw current time and a client clock
|
|
117
95
|
// slightly ahead of node time gets sporadic submit failures.
|
|
118
96
|
// `stoaGasMeta()` supplies both `creationTime` (via `safeCreationTime()`)
|
|
119
|
-
// and the `gasPrice` derived from that exact value
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
// rejected as underpriced.
|
|
97
|
+
// and the `gasPrice` derived from that exact value — see the gas-pricing
|
|
98
|
+
// note above. The chain-wide minimum price rises over time, so a
|
|
99
|
+
// hardcoded `gasPrice` would eventually be rejected as underpriced.
|
|
123
100
|
gasLimit: 2500,
|
|
124
101
|
ttl: 28800,
|
|
125
|
-
...stoaGasMeta(),
|
|
102
|
+
...stoaGasMeta(safeCreationTime()),
|
|
126
103
|
})
|
|
127
104
|
.setNetworkId(KADENA_NETWORK)
|
|
128
105
|
.createTransaction();
|
|
@@ -157,7 +134,7 @@ export function buildCTransferAcross(params) {
|
|
|
157
134
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
158
135
|
gasLimit: 2500,
|
|
159
136
|
ttl: 28800,
|
|
160
|
-
...stoaGasMeta(),
|
|
137
|
+
...stoaGasMeta(safeCreationTime()),
|
|
161
138
|
})
|
|
162
139
|
.setNetworkId(KADENA_NETWORK)
|
|
163
140
|
.createTransaction();
|
|
@@ -181,7 +158,7 @@ export function buildCTransferAcross(params) {
|
|
|
181
158
|
senderAccount: "stoa-xchain-gas",
|
|
182
159
|
gasLimit: 850, // must be <= 850 for the stoa-xchain-gas guard
|
|
183
160
|
ttl: 28800,
|
|
184
|
-
...stoaGasMeta(),
|
|
161
|
+
...stoaGasMeta(safeCreationTime()),
|
|
185
162
|
})
|
|
186
163
|
.setNetworkId(KADENA_NETWORK)
|
|
187
164
|
.createTransaction();
|
|
@@ -377,7 +354,7 @@ export function buildContinuationTransaction(pactId, proof, targetChain, gasPaye
|
|
|
377
354
|
senderAccount: gasPayerAccount,
|
|
378
355
|
gasLimit: 850, // must be <= 850 for the stoa-xchain-gas guard
|
|
379
356
|
ttl: 28800,
|
|
380
|
-
...stoaGasMeta(),
|
|
357
|
+
...stoaGasMeta(safeCreationTime()),
|
|
381
358
|
})
|
|
382
359
|
.setNetworkId(KADENA_NETWORK)
|
|
383
360
|
.createTransaction();
|
|
@@ -6,7 +6,7 @@ import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KA
|
|
|
6
6
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
7
7
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
8
8
|
import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/signing";
|
|
9
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
9
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
10
10
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
11
11
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
12
12
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
@@ -62,7 +62,7 @@ export async function executeSingleSwapWithSlippage(params) {
|
|
|
62
62
|
.addData('slippage-bounds', slippageBoundsObj)
|
|
63
63
|
.setMeta({
|
|
64
64
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
65
|
-
|
|
65
|
+
...stoaGasMeta(safeCreationTime()),
|
|
66
66
|
chainId: KADENA_CHAIN_ID,
|
|
67
67
|
gasLimit: gasLimitOverride || gasLimit,
|
|
68
68
|
})
|
|
@@ -125,7 +125,7 @@ export async function executeSingleSwapNoSlippage(params) {
|
|
|
125
125
|
})
|
|
126
126
|
.setMeta({
|
|
127
127
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
128
|
-
|
|
128
|
+
...stoaGasMeta(safeCreationTime()),
|
|
129
129
|
chainId: KADENA_CHAIN_ID,
|
|
130
130
|
gasLimit: gasLimitOverride || gasLimit,
|
|
131
131
|
})
|
|
@@ -194,7 +194,7 @@ export async function executeMultiSwapWithSlippage(params) {
|
|
|
194
194
|
.addData('slippage-bounds', slippageBoundsObj)
|
|
195
195
|
.setMeta({
|
|
196
196
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
197
|
-
|
|
197
|
+
...stoaGasMeta(safeCreationTime()),
|
|
198
198
|
chainId: KADENA_CHAIN_ID,
|
|
199
199
|
gasLimit: gasLimitOverride || gasLimit,
|
|
200
200
|
})
|
|
@@ -259,7 +259,7 @@ export async function executeMultiSwapNoSlippage(params) {
|
|
|
259
259
|
})
|
|
260
260
|
.setMeta({
|
|
261
261
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
262
|
-
|
|
262
|
+
...stoaGasMeta(safeCreationTime()),
|
|
263
263
|
chainId: KADENA_CHAIN_ID,
|
|
264
264
|
gasLimit: gasLimitOverride || gasLimit,
|
|
265
265
|
})
|
|
@@ -6,7 +6,7 @@ import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KA
|
|
|
6
6
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
7
7
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
8
8
|
import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/signing";
|
|
9
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
9
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
10
10
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
11
11
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
12
12
|
/**
|
|
@@ -93,7 +93,7 @@ export async function executeSmartSwapWithSlippage(params) {
|
|
|
93
93
|
.addData("slippage-bounds", slippageObj)
|
|
94
94
|
.setMeta({
|
|
95
95
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
96
|
-
|
|
96
|
+
...stoaGasMeta(safeCreationTime()),
|
|
97
97
|
chainId: KADENA_CHAIN_ID,
|
|
98
98
|
gasLimit: gasLimitOverride ?? gasLimit,
|
|
99
99
|
})
|
|
@@ -137,7 +137,7 @@ export async function executeSmartSwapNoSlippage(params) {
|
|
|
137
137
|
})
|
|
138
138
|
.setMeta({
|
|
139
139
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
140
|
-
|
|
140
|
+
...stoaGasMeta(safeCreationTime()),
|
|
141
141
|
chainId: KADENA_CHAIN_ID,
|
|
142
142
|
gasLimit: gasLimitOverride ?? gasLimit,
|
|
143
143
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
1
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
2
2
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
3
3
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
4
4
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
@@ -7,47 +7,6 @@ import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/sign
|
|
|
7
7
|
import { createSimulationError, logDetailedError } from "@stoachain/stoa-core/errors";
|
|
8
8
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
9
9
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
10
|
-
/**
|
|
11
|
-
* Yin Engine — StoaChain's time-varying minimum gas price.
|
|
12
|
-
*
|
|
13
|
-
* TEMPORARY LOCAL COPY, identical to the one in `crossChainFunctions.ts`
|
|
14
|
-
* (v4.5.0). Both belong in `@stoachain/stoa-core/gas` long-term — that package
|
|
15
|
-
* still exposes only the static `GAS_PRICE_MIN_ANU = 10_000`, which is the
|
|
16
|
-
* genesis floor and has been stale since 2026-02-23. Delete every copy in the
|
|
17
|
-
* same change that consumes the chain-generic version.
|
|
18
|
-
*
|
|
19
|
-
* The floor starts at 10,000 ANU at genesis and rises by 1 ANU every 3 hours,
|
|
20
|
-
* capped at 400,000 ANU. Source of truth: `UC_MinimumGasPriceANU` in
|
|
21
|
-
* `pact/stoa-coin/new-coin.pact` (evaluated against `(at "block-time"
|
|
22
|
-
* (chain-data))` on-chain — creationTime is a close client-side proxy for it).
|
|
23
|
-
*
|
|
24
|
-
* This applies to gas-station-paid transactions too: `DALOS.GAS_PAYER` decides
|
|
25
|
-
* WHO pays, not HOW LITTLE. The chain-wide "gasPrice must be >= the live
|
|
26
|
-
* floor" rule is checked before the payer guard ever runs, so a transaction
|
|
27
|
-
* left at the client's `1.0e-8` default is rejected as underpriced no matter
|
|
28
|
-
* how well-funded the Ouronet Gas Station is.
|
|
29
|
-
*/
|
|
30
|
-
const YIN_GENESIS_TIME_S = 1771869600; // 2026-02-23T18:00:00Z — tick 0
|
|
31
|
-
const YIN_GENESIS_MIN_GAS_ANU = 10000;
|
|
32
|
-
const YIN_MAX_GAS_ANU = 400000;
|
|
33
|
-
const YIN_GAS_PRICE_INTERVAL_S = 10800; // 3 h per tick
|
|
34
|
-
function minGasPriceAnu(creationTimeS) {
|
|
35
|
-
const elapsed = creationTimeS - YIN_GENESIS_TIME_S;
|
|
36
|
-
const ticks = elapsed <= 0 ? 0 : Math.floor(elapsed / YIN_GAS_PRICE_INTERVAL_S);
|
|
37
|
-
return Math.min(YIN_GENESIS_MIN_GAS_ANU + ticks, YIN_MAX_GAS_ANU);
|
|
38
|
-
}
|
|
39
|
-
/** Built by string padding, never float division — avoids exponential notation / precision loss. */
|
|
40
|
-
function anuToStoaNumber(anu) {
|
|
41
|
-
return Number("0." + String(anu).padStart(12, "0"));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* One clock read: the `creationTime` to stamp and the `gasPrice` derived
|
|
45
|
-
* FROM THAT EXACT VALUE, so the two can never disagree.
|
|
46
|
-
*/
|
|
47
|
-
function stoaGasMeta() {
|
|
48
|
-
const creationTime = safeCreationTime();
|
|
49
|
-
return { creationTime, gasPrice: anuToStoaNumber(minGasPriceAnu(creationTime)) };
|
|
50
|
-
}
|
|
51
10
|
/**
|
|
52
11
|
* Query RotateGuard info object from the chain.
|
|
53
12
|
* (ouronet-ns.DALOS-INFO.DALOS-INFO|URC_RotateGuard <patron> <account>)
|
|
@@ -112,13 +71,15 @@ export async function rotateGuard(params) {
|
|
|
112
71
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
113
72
|
chainId: KADENA_CHAIN_ID,
|
|
114
73
|
gasLimit: gasLimitOverride || gasLimit,
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
|
|
74
|
+
// One clock read for both fields: `stoaGasMeta` (the canonical Yin
|
|
75
|
+
// Engine in `@stoachain/stoa-core/gas`) prices the transaction against
|
|
76
|
+
// the very `creationTime` it stamps, so a tick crossing between two
|
|
77
|
+
// separate reads can never underprice it. `safeCreationTime()` keeps
|
|
78
|
+
// this package's -30s skew (F-BUG-002) and the price follows it.
|
|
79
|
+
// Pre-4.5.1 only `creationTime` was set and `gasPrice` fell back to
|
|
80
|
+
// the client's `1.0e-8` default — the genesis floor — so every
|
|
81
|
+
// rotation after the floor's first tick was rejected as underpriced.
|
|
82
|
+
...stoaGasMeta(safeCreationTime()),
|
|
122
83
|
})
|
|
123
84
|
.setNetworkId(KADENA_NETWORK)
|
|
124
85
|
// Gas Station key: GAS_PAYER capability
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
1
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
2
2
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
3
3
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
4
4
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
@@ -141,7 +141,7 @@ export async function kpayBuy(patronAccount, buyerAccount, kpayAmount, isNative,
|
|
|
141
141
|
})
|
|
142
142
|
.setMeta({
|
|
143
143
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
144
|
-
|
|
144
|
+
...stoaGasMeta(safeCreationTime()), // Gas station
|
|
145
145
|
chainId: KADENA_CHAIN_ID,
|
|
146
146
|
gasLimit: gasLimitOverride || gasLimit,
|
|
147
147
|
})
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* coil/pension/info-one preview surface (locked here because the original tail-block
|
|
5
5
|
* comment "Export new coiling functions for AURYN and WSTOA" places them in the coil domain).
|
|
6
6
|
*/
|
|
7
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
7
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
8
8
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
9
9
|
import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
|
|
10
10
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -93,7 +93,7 @@ ouroAmount) {
|
|
|
93
93
|
})
|
|
94
94
|
.setMeta({
|
|
95
95
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
96
|
-
|
|
96
|
+
...stoaGasMeta(safeCreationTime()),
|
|
97
97
|
chainId: KADENA_CHAIN_ID,
|
|
98
98
|
gasLimit: gasLimitOverride || gasLimit,
|
|
99
99
|
})
|
|
@@ -152,7 +152,7 @@ ouroAmount) {
|
|
|
152
152
|
})
|
|
153
153
|
.setMeta({
|
|
154
154
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
155
|
-
|
|
155
|
+
...stoaGasMeta(safeCreationTime()),
|
|
156
156
|
chainId: KADENA_CHAIN_ID,
|
|
157
157
|
gasLimit: gasLimitOverride || gasLimit,
|
|
158
158
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ouroMovieBoosterFunctions.ts
|
|
3
3
|
* Sparks balance / movie-booster purchase / firestarter execution + max-buy probe.
|
|
4
4
|
*/
|
|
5
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
5
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
6
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
7
7
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -47,7 +47,7 @@ guardAccount // The guard account from the Ouro account
|
|
|
47
47
|
})
|
|
48
48
|
.setMeta({
|
|
49
49
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
50
|
-
|
|
50
|
+
...stoaGasMeta(safeCreationTime()),
|
|
51
51
|
chainId: KADENA_CHAIN_ID,
|
|
52
52
|
gasLimit: gasLimitOverride || gasLimit,
|
|
53
53
|
})
|
|
@@ -90,7 +90,7 @@ guardAccount // The guard account from the Ouro account
|
|
|
90
90
|
})
|
|
91
91
|
.setMeta({
|
|
92
92
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
93
|
-
|
|
93
|
+
...stoaGasMeta(safeCreationTime()),
|
|
94
94
|
chainId: KADENA_CHAIN_ID,
|
|
95
95
|
gasLimit: gasLimit,
|
|
96
96
|
})
|
|
@@ -164,7 +164,7 @@ guardAccount // The guard account from the Ouro account
|
|
|
164
164
|
})
|
|
165
165
|
.setMeta({
|
|
166
166
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
167
|
-
|
|
167
|
+
...stoaGasMeta(safeCreationTime()),
|
|
168
168
|
chainId: KADENA_CHAIN_ID,
|
|
169
169
|
gasLimit: gasLimitOverride || gasLimit,
|
|
170
170
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ouroRotateFunctions.ts
|
|
3
3
|
* Kadena payment-key rotation for Ouronet accounts (multi-signer flow).
|
|
4
4
|
*/
|
|
5
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
5
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
6
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
7
7
|
import { safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -11,47 +11,6 @@ import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/sign
|
|
|
11
11
|
import { createSimulationError, logDetailedError } from "@stoachain/stoa-core/errors";
|
|
12
12
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
13
13
|
import { getLogger } from "@stoachain/stoa-core/observability";
|
|
14
|
-
/**
|
|
15
|
-
* Yin Engine — StoaChain's time-varying minimum gas price.
|
|
16
|
-
*
|
|
17
|
-
* TEMPORARY LOCAL COPY, identical to the one in `crossChainFunctions.ts`
|
|
18
|
-
* (v4.5.0). Both belong in `@stoachain/stoa-core/gas` long-term — that package
|
|
19
|
-
* still exposes only the static `GAS_PRICE_MIN_ANU = 10_000`, which is the
|
|
20
|
-
* genesis floor and has been stale since 2026-02-23. Delete every copy in the
|
|
21
|
-
* same change that consumes the chain-generic version.
|
|
22
|
-
*
|
|
23
|
-
* The floor starts at 10,000 ANU at genesis and rises by 1 ANU every 3 hours,
|
|
24
|
-
* capped at 400,000 ANU. Source of truth: `UC_MinimumGasPriceANU` in
|
|
25
|
-
* `pact/stoa-coin/new-coin.pact` (evaluated against `(at "block-time"
|
|
26
|
-
* (chain-data))` on-chain — creationTime is a close client-side proxy for it).
|
|
27
|
-
*
|
|
28
|
-
* This applies to gas-station-paid transactions too: `DALOS.GAS_PAYER` decides
|
|
29
|
-
* WHO pays, not HOW LITTLE. The chain-wide "gasPrice must be >= the live
|
|
30
|
-
* floor" rule is checked before the payer guard ever runs, so a transaction
|
|
31
|
-
* left at the client's `1.0e-8` default is rejected as underpriced no matter
|
|
32
|
-
* how well-funded the Ouronet Gas Station is.
|
|
33
|
-
*/
|
|
34
|
-
const YIN_GENESIS_TIME_S = 1771869600; // 2026-02-23T18:00:00Z — tick 0
|
|
35
|
-
const YIN_GENESIS_MIN_GAS_ANU = 10000;
|
|
36
|
-
const YIN_MAX_GAS_ANU = 400000;
|
|
37
|
-
const YIN_GAS_PRICE_INTERVAL_S = 10800; // 3 h per tick
|
|
38
|
-
function minGasPriceAnu(creationTimeS) {
|
|
39
|
-
const elapsed = creationTimeS - YIN_GENESIS_TIME_S;
|
|
40
|
-
const ticks = elapsed <= 0 ? 0 : Math.floor(elapsed / YIN_GAS_PRICE_INTERVAL_S);
|
|
41
|
-
return Math.min(YIN_GENESIS_MIN_GAS_ANU + ticks, YIN_MAX_GAS_ANU);
|
|
42
|
-
}
|
|
43
|
-
/** Built by string padding, never float division — avoids exponential notation / precision loss. */
|
|
44
|
-
function anuToStoaNumber(anu) {
|
|
45
|
-
return Number("0." + String(anu).padStart(12, "0"));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* One clock read: the `creationTime` to stamp and the `gasPrice` derived
|
|
49
|
-
* FROM THAT EXACT VALUE, so the two can never disagree.
|
|
50
|
-
*/
|
|
51
|
-
function stoaGasMeta() {
|
|
52
|
-
const creationTime = safeCreationTime();
|
|
53
|
-
return { creationTime, gasPrice: anuToStoaNumber(minGasPriceAnu(creationTime)) };
|
|
54
|
-
}
|
|
55
14
|
/**
|
|
56
15
|
* Query RotateKadena info object from the chain.
|
|
57
16
|
* (ouronet-ns.INFO-ZERO.DALOS-INFO|URC_RotateKadena <patron> <account>)
|
|
@@ -113,13 +72,15 @@ export async function rotateKadenaPaymentKey(patronAddress, accountAddress, newP
|
|
|
113
72
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
114
73
|
chainId: KADENA_CHAIN_ID,
|
|
115
74
|
gasLimit: gasLimitOverride || gasLimit,
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
|
|
75
|
+
// One clock read for both fields: `stoaGasMeta` (the canonical Yin
|
|
76
|
+
// Engine in `@stoachain/stoa-core/gas`) prices the transaction against
|
|
77
|
+
// the very `creationTime` it stamps, so a tick crossing between two
|
|
78
|
+
// separate reads can never underprice it. `safeCreationTime()` keeps
|
|
79
|
+
// this package's -30s skew (F-BUG-002) and the price follows it.
|
|
80
|
+
// Pre-4.5.1 only `creationTime` was set and `gasPrice` fell back to
|
|
81
|
+
// the client's `1.0e-8` default — the genesis floor — so every
|
|
82
|
+
// payment-key rotation after the first tick was rejected as underpriced.
|
|
83
|
+
...stoaGasMeta(safeCreationTime()),
|
|
123
84
|
})
|
|
124
85
|
.setNetworkId(KADENA_NETWORK)
|
|
125
86
|
// Gas Station key: GAS_PAYER capability (SEPARATE from guard keys)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ouroSubCompressFunctions.ts
|
|
3
3
|
* Sublimate (OURO -> IGNIS) and compress (IGNIS -> OURO) execution + preview/info reads.
|
|
4
4
|
*/
|
|
5
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
5
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
6
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
7
7
|
import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -27,7 +27,7 @@ export async function sublimateOuroToIgnis(ouroAccount, kadenaAccount, guard, ta
|
|
|
27
27
|
})
|
|
28
28
|
.setMeta({
|
|
29
29
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
30
|
-
|
|
30
|
+
...stoaGasMeta(safeCreationTime()),
|
|
31
31
|
chainId: KADENA_CHAIN_ID,
|
|
32
32
|
gasLimit: gasLimitOverride || gasLimit,
|
|
33
33
|
})
|
|
@@ -87,7 +87,7 @@ export async function compressIgnisToOuro(ouroAccount, kadenaAccount, guard, ign
|
|
|
87
87
|
})
|
|
88
88
|
.setMeta({
|
|
89
89
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
90
|
-
|
|
90
|
+
...stoaGasMeta(safeCreationTime()),
|
|
91
91
|
chainId: KADENA_CHAIN_ID,
|
|
92
92
|
gasLimit: gasLimitOverride || gasLimit,
|
|
93
93
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ouroTransferFunctions.ts
|
|
3
3
|
* Single-token DPTF transfer execution via TS01-C1.DPTF|C_Transfer.
|
|
4
4
|
*/
|
|
5
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
5
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
6
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
7
7
|
import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -27,7 +27,7 @@ guardAccount // The guard account from the Ouro account
|
|
|
27
27
|
.execution(`(${KADENA_NAMESPACE}.TS01-C1.DPTF|C_Transfer "${patronAccount.address}" "${tokenId}" "${senderAccount}" "${receiverAccount}" ${decimalAmount} ${method})`)
|
|
28
28
|
.setMeta({
|
|
29
29
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
30
|
-
|
|
30
|
+
...stoaGasMeta(safeCreationTime()),
|
|
31
31
|
chainId: KADENA_CHAIN_ID,
|
|
32
32
|
gasLimit: gasLimitOverride || gasLimit,
|
|
33
33
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ouroUrStoaFunctions.ts
|
|
3
3
|
* UrStoa account-existence probe, unwrap-info read, and unwrap execution (parallel to UnwrapStoa).
|
|
4
4
|
*/
|
|
5
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
5
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
6
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
7
7
|
import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -88,7 +88,7 @@ export async function executeUnwrapUrStoa(params) {
|
|
|
88
88
|
pred: "keys-all",
|
|
89
89
|
});
|
|
90
90
|
builder = builder
|
|
91
|
-
.setMeta({ senderAccount: STOA_AUTONOMIC_OURONETGASSTATION, chainId: KADENA_CHAIN_ID,
|
|
91
|
+
.setMeta({ senderAccount: STOA_AUTONOMIC_OURONETGASSTATION, chainId: KADENA_CHAIN_ID, ...stoaGasMeta(safeCreationTime()),
|
|
92
92
|
gasLimit: effectiveGasLimit })
|
|
93
93
|
.setNetworkId(KADENA_NETWORK)
|
|
94
94
|
.addSigner(gasStationKey.publicKey, (w) => [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ouroWrapFunctions.ts
|
|
3
3
|
* KDA wrap/unwrap and unwrap-stoa execution + supporting reads.
|
|
4
4
|
*/
|
|
5
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
5
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
6
6
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, STOA_AUTONOMIC_LIQUIDPOT, KADENA_NETWORK, } from "../constants/index.js";
|
|
7
7
|
import { safeCreationTime, formatDecimalForPact } from "@stoachain/stoa-core/pact";
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -32,7 +32,7 @@ amount) {
|
|
|
32
32
|
})
|
|
33
33
|
.setMeta({
|
|
34
34
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
35
|
-
|
|
35
|
+
...stoaGasMeta(safeCreationTime()),
|
|
36
36
|
chainId: KADENA_CHAIN_ID,
|
|
37
37
|
gasLimit: gasLimitOverride || gasLimit,
|
|
38
38
|
})
|
|
@@ -84,7 +84,7 @@ amount) {
|
|
|
84
84
|
.execution(`(${KADENA_NAMESPACE}.TS01-C2.LQD|C_UnwrapStoa "${patronAccount.address}" "${unwrapperAccount}" ${decimalAmount})`)
|
|
85
85
|
.setMeta({
|
|
86
86
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
87
|
-
|
|
87
|
+
...stoaGasMeta(safeCreationTime()),
|
|
88
88
|
chainId: KADENA_CHAIN_ID,
|
|
89
89
|
gasLimit: gasLimitOverride || gasLimit,
|
|
90
90
|
})
|
|
@@ -195,7 +195,7 @@ export async function executeUnwrapStoa(params) {
|
|
|
195
195
|
pred: "keys-all",
|
|
196
196
|
});
|
|
197
197
|
builder = builder
|
|
198
|
-
.setMeta({ senderAccount: STOA_AUTONOMIC_OURONETGASSTATION, chainId: KADENA_CHAIN_ID,
|
|
198
|
+
.setMeta({ senderAccount: STOA_AUTONOMIC_OURONETGASSTATION, chainId: KADENA_CHAIN_ID, ...stoaGasMeta(safeCreationTime()),
|
|
199
199
|
gasLimit: effectiveGasLimit })
|
|
200
200
|
.setNetworkId(KADENA_NETWORK)
|
|
201
201
|
// Gas Station: GAS_PAYER + coin.TRANSFER
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
1
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
2
2
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
|
|
3
3
|
import { formatDecimalForPact, safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
4
4
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
@@ -20,7 +20,7 @@ export async function brumateWkdaToPkda(ouroAccount, kadenaAccount, guard, wkdaA
|
|
|
20
20
|
})
|
|
21
21
|
.setMeta({
|
|
22
22
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
23
|
-
|
|
23
|
+
...stoaGasMeta(safeCreationTime()),
|
|
24
24
|
chainId: KADENA_CHAIN_ID,
|
|
25
25
|
gasLimit: gasLimitOverride || gasLimit,
|
|
26
26
|
})
|
|
@@ -65,7 +65,7 @@ export async function constrictLkdaToPkda(ouroAccount, kadenaAccount, guard, lkd
|
|
|
65
65
|
})
|
|
66
66
|
.setMeta({
|
|
67
67
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
68
|
-
|
|
68
|
+
...stoaGasMeta(safeCreationTime()),
|
|
69
69
|
chainId: KADENA_CHAIN_ID,
|
|
70
70
|
gasLimit: gasLimitOverride || gasLimit,
|
|
71
71
|
})
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
9
9
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
10
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
10
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
11
11
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
12
12
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, KADENA_NETWORK, STOA_AUTONOMIC_OURONETGASSTATION, } from "../constants/index.js";
|
|
13
13
|
import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/signing";
|
|
@@ -176,7 +176,7 @@ export async function executeNativeUrStoaTransfer(params) {
|
|
|
176
176
|
.execution(pactCode)
|
|
177
177
|
.setMeta({
|
|
178
178
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
179
|
-
|
|
179
|
+
...stoaGasMeta(safeCreationTime()),
|
|
180
180
|
chainId: KADENA_CHAIN_ID,
|
|
181
181
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
182
182
|
})
|
|
@@ -280,7 +280,7 @@ export async function executeNativeUrStoaTransfer(params) {
|
|
|
280
280
|
.execution(pactCode)
|
|
281
281
|
.setMeta({
|
|
282
282
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
283
|
-
|
|
283
|
+
...stoaGasMeta(safeCreationTime()),
|
|
284
284
|
chainId: KADENA_CHAIN_ID,
|
|
285
285
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
286
286
|
})
|
|
@@ -346,7 +346,7 @@ export async function executeStakeUrStoa(params) {
|
|
|
346
346
|
.execution(`(coin.C_URV|Stake "${paymentKeyAddress}" ${validatedAmount})`)
|
|
347
347
|
.setMeta({
|
|
348
348
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
349
|
-
|
|
349
|
+
...stoaGasMeta(safeCreationTime()),
|
|
350
350
|
chainId: KADENA_CHAIN_ID,
|
|
351
351
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
352
352
|
})
|
|
@@ -380,7 +380,7 @@ export async function executeUnstakeUrStoa(params) {
|
|
|
380
380
|
.execution(`(coin.C_URV|Unstake "${paymentKeyAddress}" ${validatedAmount})`)
|
|
381
381
|
.setMeta({
|
|
382
382
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
383
|
-
|
|
383
|
+
...stoaGasMeta(safeCreationTime()),
|
|
384
384
|
chainId: KADENA_CHAIN_ID,
|
|
385
385
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
386
386
|
})
|
|
@@ -445,7 +445,7 @@ export async function executeCollectUrStoa(params) {
|
|
|
445
445
|
.execution(code)
|
|
446
446
|
.setMeta({
|
|
447
447
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
448
|
-
|
|
448
|
+
...stoaGasMeta(safeCreationTime()),
|
|
449
449
|
chainId: KADENA_CHAIN_ID,
|
|
450
450
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
451
451
|
})
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Pact } from "@stoachain/kadena-stoic-legacy/client";
|
|
6
6
|
import { getFailoverClient } from "@stoachain/stoa-core/network";
|
|
7
|
-
import { calculateAutoGasLimit } from "@stoachain/stoa-core/gas";
|
|
7
|
+
import { calculateAutoGasLimit, stoaGasMeta } from "@stoachain/stoa-core/gas";
|
|
8
8
|
import { KADENA_CHAIN_ID, KADENA_NAMESPACE, KADENA_NETWORK, STOA_AUTONOMIC_OURONETGASSTATION, STOA_AUTONOMIC_LIQUIDPOT, } from "../constants/index.js";
|
|
9
9
|
import { formatDecimalForPact, safeCreationTime } from "@stoachain/stoa-core/pact";
|
|
10
10
|
import { pactRead } from "@stoachain/stoa-core/reads";
|
|
@@ -79,7 +79,7 @@ export async function executeWrapStoa(params) {
|
|
|
79
79
|
.execution(`(${KADENA_NAMESPACE}.TS01-C2.LQD|C_WrapStoa "${patronAddress}" "${wrapperAddress}" ${amount})`)
|
|
80
80
|
.setMeta({
|
|
81
81
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
82
|
-
|
|
82
|
+
...stoaGasMeta(safeCreationTime()),
|
|
83
83
|
chainId: KADENA_CHAIN_ID,
|
|
84
84
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
85
85
|
})
|
|
@@ -97,7 +97,7 @@ export async function executeWrapStoa(params) {
|
|
|
97
97
|
.execution(`(${KADENA_NAMESPACE}.TS01-C2.LQD|C_WrapStoa "${patronAddress}" "${wrapperAddress}" ${amount})`)
|
|
98
98
|
.setMeta({
|
|
99
99
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
100
|
-
|
|
100
|
+
...stoaGasMeta(safeCreationTime()),
|
|
101
101
|
chainId: KADENA_CHAIN_ID,
|
|
102
102
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
103
103
|
})
|
|
@@ -174,7 +174,7 @@ export async function executeWrapUrStoa(params) {
|
|
|
174
174
|
.execution(`(${KADENA_NAMESPACE}.TS01-C2.LQD|C_WrapUrStoa "${patronAddress}" "${wrapperAddress}" ${amount})`)
|
|
175
175
|
.setMeta({
|
|
176
176
|
senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
|
|
177
|
-
|
|
177
|
+
...stoaGasMeta(safeCreationTime()),
|
|
178
178
|
chainId: KADENA_CHAIN_ID,
|
|
179
179
|
gasLimit: gasLimitOverride ?? 2000000,
|
|
180
180
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouronet/ouronet-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Ouronet-specific business logic for the Ouronet protocol on StoaChain — interactions/* read+execute functions for the ouronet-ns Pact modules, the Codex encrypted-multi-wallet format, Ouronet protocol accounts and tokens. Depends on @stoachain/stoa-core for chain-generic infrastructure (signing, wallet, crypto, network, etc.).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"clean": "rimraf dist"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@stoachain/kadena-stoic-legacy": "4.
|
|
52
|
-
"@stoachain/stoa-core": "4.
|
|
51
|
+
"@stoachain/kadena-stoic-legacy": "4.4.0",
|
|
52
|
+
"@stoachain/stoa-core": "4.4.0"
|
|
53
53
|
},
|
|
54
54
|
"repository": {
|
|
55
55
|
"type": "git",
|