[PR #143] [MERGED] SMP 0.29.0: one market price per item, to buy and to sell #146

Closed
opened 2026-11-03 04:03:38 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-mods/pull/143
Author: @ludovic111
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/smp-one-price


📝 Commits (2)

  • 59f2388 SMP 0.29.0: one market price per item, to buy and to sell
  • 61e99d5 SMP 0.29.0: carry the old price history and futures entries over

📊 Changes

11 files changed (+1045 additions, -396 deletions)

View changed files

📝 native/smp/Cargo.lock (+1 -1)
📝 native/smp/Cargo.toml (+1 -1)
📝 native/smp/README.md (+37 -33)
📝 native/smp/mixins/smp/glue.rs (+22 -18)
📝 native/smp/mixins/smp/horizon-mixin.toml (+1 -1)
📝 native/smp/mixins/smp/smp_futures.rs (+35 -0)
📝 native/smp/mixins/smp/smp_market.rs (+505 -179)
📝 native/smp/mixins/smp/smp_market_prices.rs (+325 -102)
📝 native/smp/mixins/smp/smp_recipes.rs (+50 -1)
📝 native/smp/mixins/smp/smp_shop.rs (+1 -1)
📝 native/smp/proof.py (+67 -59)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Ludovic: "make it so that the stock market of the items is same price for buy and sell the current by and sell prices dont make sence".

Why the numbers didn't make sense:

  • every item had two prices, 4x apart (diamond: bought for 400, sold for 100);
  • prices moved only on the minute timer, so a trade never changed the price you had just seen;
  • /worth, the menus, market.json and the site all showed both numbers.

Now:

  • One price per item, the geometric mean of the old pair (diamond 200, iron 15, wheat 2, coal 4, emerald 40). It shows in /worth, /market, /shop, the chart maps and web/market.json (price; buy and sell repeat it on the sides the market trades). A config with two prices gets one at load, logged as "one price now". Buy-only and sell-only items stay that way.
  • Priced along the curve. Each unit moves the log price by 1%/depth, so N items are worth the area under the curve, rounded against the trader. Buy then sell back = −tax, exactly. Tests cover N = 1, 64 and past the band, plus a 5,000-step random fuzz with drift.
  • 5% a minute, all trades together. Past that, a purchase is cut short and a sale keeps the rest. The first version priced the extra units flat at the edge; the fuzz found +119 coins from slow buying while the drift pulled the price back, then a flat dump.
  • Recipes: items linked by recipes share one moving price, and a block moves it as its 9 ingots do. The vanilla-recipe test now also checks every item at the worst drift (inputs at 0.6×, output at 1.6×). There are no loops. As a control, once the gold block and its ingots no longer share a price, the test finds the gold block.
  • The tax is a separate receipt line: "Sold 3 diamond at 198 coins each: 595 coins." / "Tax 2%: -12 coins. You get 583 coins."
  • Daily sell limits are unchanged.

Site: horizon-rust/horizon-site#40 (one Price column).

Checks:

  • cargo test --lib with SMP_VANILLA_DATA: 157 passed;
  • native.py check smp ✓;
  • native.py proof smp (two runs: fixed prices, then moving prices + shop + market + push to Kira): result in a comment below.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-mods/pull/143 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/smp-one-price` --- ### 📝 Commits (2) - [`59f2388`](https://github.com/horizon-rust/horizon-mods/commit/59f2388a0fe2a84aef4a51a92f7673ce18708f4b) SMP 0.29.0: one market price per item, to buy and to sell - [`61e99d5`](https://github.com/horizon-rust/horizon-mods/commit/61e99d5df7f27c5940ceebbbe7113fb0e76f48b7) SMP 0.29.0: carry the old price history and futures entries over ### 📊 Changes **11 files changed** (+1045 additions, -396 deletions) <details> <summary>View changed files</summary> 📝 `native/smp/Cargo.lock` (+1 -1) 📝 `native/smp/Cargo.toml` (+1 -1) 📝 `native/smp/README.md` (+37 -33) 📝 `native/smp/mixins/smp/glue.rs` (+22 -18) 📝 `native/smp/mixins/smp/horizon-mixin.toml` (+1 -1) 📝 `native/smp/mixins/smp/smp_futures.rs` (+35 -0) 📝 `native/smp/mixins/smp/smp_market.rs` (+505 -179) 📝 `native/smp/mixins/smp/smp_market_prices.rs` (+325 -102) 📝 `native/smp/mixins/smp/smp_recipes.rs` (+50 -1) 📝 `native/smp/mixins/smp/smp_shop.rs` (+1 -1) 📝 `native/smp/proof.py` (+67 -59) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Ludovic: *"make it so that the stock market of the items is same price for buy and sell the current by and sell prices dont make sence"*. **Why the numbers didn't make sense:** - every item had two prices, 4x apart (diamond: bought for 400, sold for 100); - prices moved only on the minute timer, so a trade never changed the price you had just seen; - `/worth`, the menus, market.json and the site all showed both numbers. **Now:** - **One price per item**, the geometric mean of the old pair (diamond 200, iron 15, wheat 2, coal 4, emerald 40). It shows in `/worth`, `/market`, `/shop`, the chart maps and `web/market.json` (`price`; `buy` and `sell` repeat it on the sides the market trades). A config with two prices gets one at load, logged as "one price now". Buy-only and sell-only items stay that way. - **Priced along the curve.** Each unit moves the log price by 1%/depth, so N items are worth the area under the curve, rounded against the trader. Buy then sell back = −tax, exactly. Tests cover N = 1, 64 and past the band, plus a 5,000-step random fuzz with drift. - **5% a minute**, all trades together. Past that, a purchase is cut short and a sale keeps the rest. The first version priced the extra units flat at the edge; the fuzz found +119 coins from slow buying while the drift pulled the price back, then a flat dump. - **Recipes:** items linked by recipes share one moving price, and a block moves it as its 9 ingots do. The vanilla-recipe test now also checks every item at the worst drift (inputs at 0.6×, output at 1.6×). There are no loops. As a control, once the gold block and its ingots no longer share a price, the test finds the gold block. - **The tax is a separate receipt line:** "Sold 3 diamond at 198 coins each: 595 coins." / "Tax 2%: -12 coins. You get 583 coins." - Daily sell limits are unchanged. Site: horizon-rust/horizon-site#40 (one Price column). **Checks:** - `cargo test --lib` with `SMP_VANILLA_DATA`: 157 passed; - `native.py check smp` ✓; - `native.py proof smp` (two runs: fixed prices, then moving prices + shop + market + push to Kira): result in a comment below. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:03:38 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-mods#146
No description provided.