Skip to content

Commit

Permalink
Fix dispensers price_normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Dec 23, 2024
1 parent 18a8709 commit 4945f2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion counterparty-core/counterpartycore/lib/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,15 @@ def inject_normalized_quantity(item, field_name, asset_info):
return item

if item[field_name] is not None:
if field_name in ["give_price", "get_price", "forward_price", "backward_price", "price"]:
if field_name in ["give_price", "get_price", "forward_price", "backward_price"]:
# use 16 decimal places for prices
item[field_name + "_normalized"] = normalize_price(item[field_name])
elif field_name == "price":
if "satoshirate" in item:
price = D(item["satoshirate_normalized"]) / D(item["give_quantity_normalized"])
item[field_name + "_normalized"] = normalize_price(price)
else:
item[field_name + "_normalized"] = normalize_price(item[field_name])
else:
item[field_name + "_normalized"] = (
divide(item[field_name], 10**8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8254,7 +8254,7 @@
"escrow_quantity_normalized": "100",
"satoshirate_normalized": "0.00000100",
"satoshi_price_normalized": "0.00000100",
"price_normalized": "1.0000000000000000"
"price_normalized": "0.0000000100000000"
},
{
"tx_index": 108,
Expand Down
1 change: 1 addition & 0 deletions release-notes/release-notes-v10.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- Add `forward_price` and `backward_price` in order matches results
- Add parameter `exclude_with_oracle` for get dispensers routes
- Add `send_type` field in `sends` table
- Use `satoshirate_normalized` and `give_quantity_normalized` to calculate `price_normalized`

## CLI

Expand Down

0 comments on commit 4945f2e

Please sign in to comment.