Skip to content

M4: conveyor.get_prices via steemgosdk + ComputePrices#48

Open
ety001 wants to merge 1 commit into
nextfrom
m4-prices
Open

M4: conveyor.get_prices via steemgosdk + ComputePrices#48
ety001 wants to merge 1 commit into
nextfrom
m4-prices

Conversation

@ety001

@ety001 ety001 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

M4 milestone — the conveyor.get_prices RPC method (public, no auth). Fetches market data from steemd in parallel and computes three price values using steemutil's integer-arithmetic ComputePrices.

Implementation

  • Parallel fetch: GetOrderBook(1) + GetFeedHistory() + GetDynamicGlobalProperties() via goroutines + sync.WaitGroup (matching TS Promise.all)
  • Computation: steemutil.ComputePrices(ob, fh, dgp) — int64 + math/big arithmetic
  • Conversion to schema's float64 fields:
    • steem_sbd: SteemSbd.Asset.Amount / 10^3 (already the averaged conversion)
    • steem_usd: SteemUsd.Price.Convert(1 STEEM).Amount / 10^3 (raw Price, needs conversion)
    • steem_vest: SteemVest.Price.Convert(1 STEEM).Amount / 10^6 (raw Price, VESTS has 6 decimals)

Note on precision

Go uses int64 + math/big (steemutil's design) vs the TS original's float64. May differ in last-digit precision — documented as acceptable in REWRITE_PLAN.md.

Verification

  • go build ./...
  • go vet ./...
  • go test ./... ✅ — 2 new tests (fixture-based ComputePrices: 0.5 SBD, 0.5 USD, 42000 VESTS + JSON tags) + all M0-M3 tests pass

M4 milestone: the get_prices RPC method (public, no auth).

Fetches order book (limit=1), feed history, and dynamic global properties
from steemd in parallel via steemgosdk wrappers (GetOrderBook,
GetFeedHistory, GetDynamicGlobalProperties — all condenser_api). Then
calls steemutil's ComputePrices (int64 + math/big arithmetic) and
converts the result to the schema's three float64 fields:

  steem_sbd:  SteemSbd.Asset.Amount / 10^3  (already averaged)
  steem_usd:  SteemUsd.Price.Convert(1 STEEM).Amount / 10^3
  steem_vest: SteemVest.Price.Convert(1 STEEM).Amount / 10^6

Note: Go uses int64 math (steemutil design) vs TS float64; may differ
in last-digit precision. Documented as acceptable in REWRITE_PLAN.

Tests: fixture-based ComputePrices test verifying all three values
(0.5 SBD, 0.5 USD, 42000 VESTS) + JSON tag verification. All green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant