Skip to content

feat: migrate RealUnit price to Aktionariat API#3188

Merged
TaprootFreak merged 6 commits intodevelopfrom
feat/realunit-price-aktionariat-api
Feb 13, 2026
Merged

feat: migrate RealUnit price to Aktionariat API#3188
TaprootFreak merged 6 commits intodevelopfrom
feat/realunit-price-aktionariat-api

Conversation

@TaprootFreak
Copy link
Collaborator

@TaprootFreak TaprootFreak commented Feb 12, 2026

Summary

  • Replace Brokerbot smart contract calls (getPrice, getBuyPrice, getShares, settings) with the Aktionariat REST API (POST /realunit/directinvestment/getPrice)
  • Add AsyncCache (30s TTL, fallback to cache on API failure) so all methods share a single cached API call
  • Expose availableShares in all broker DTOs (BrokerbotPriceDto, BrokerbotBuyPriceDto, BrokerbotSharesDto, BrokerbotInfoDto)
  • Remove raw wei fields (pricePerShareRaw, totalPriceRaw) — breaking change, as intended
  • Use priceInEUR from the API directly for REALU↔EUR pricing across the entire system (display, buy, sell) instead of deriving EUR from CHF via market exchange rates
  • Add mock response for aktionariat.com in HttpService for local development

Changed files

File Change
realunit-blockchain.service.ts Replace smart contract with API calls, add fetchPrice() with AsyncCache
realunit-broker.dto.ts Add availableShares, remove pricePerShareRaw/totalPriceRaw
pricing-realunit.service.ts Add getDirectEurPrice() for direct REALU↔EUR pricing from API
pricing.service.ts Check getDirectEurPrice() before rule chain in getAssetPrice()
http.service.ts Add aktionariat.com mock response

EUR pricing consistency

Previously, the EUR price for REALU was derived via CHF → EUR market exchange rates (Fixer/Kraken). Now the Aktionariat API provides priceInEUR directly, which is used consistently:

  • GET /realunit/price — via PricingServicegetDirectEurPrice()
  • Buy payment info (EUR) — via TransactionHelperPricingServicegetDirectEurPrice()
  • Sell payment info (EUR) — via TransactionHelperPricingServicegetDirectEurPrice()
  • CHF and USD pricing remain unchanged (normal price rule chain)

Test plan

  • npm run build compiles without new errors
  • GET /realunit/price returns CHF (from API), EUR (from API), USD (from rule chain)
  • GET /realunit/brokerbot/info shows availableShares and buyingEnabled derived from share count
  • GET /realunit/brokerbot/buyPrice?shares=10 returns totalPrice = pricePerShare * 10
  • GET /realunit/brokerbot/shares?amount=100 returns shares = floor(100 / pricePerShare)
  • Buy with EUR uses the same EUR price as /realunit/price
  • Sell with EUR uses the same EUR price as /realunit/price
  • Verify cache fallback: API timeout still returns last known price

Replace direct smart contract reads (getPrice, getBuyPrice, getShares, settings)
with the Aktionariat REST API endpoint for price and share data. Add 30s
AsyncCache with fallback for resilience. Expose availableShares in all broker
DTOs and remove raw wei fields (pricePerShareRaw, totalPriceRaw).
The API returns priceInEUR directly, so use it for the /realunit/price
endpoint instead of deriving EUR from CHF via exchange rate conversion.
Add getDirectEurPrice() to PricingRealUnitService that returns the EUR
price from the Aktionariat API for REALU<->EUR pairs. PricingService
checks for this direct price before falling back to the rule chain,
ensuring buy/sell and display endpoints use the same EUR rate.
When a REALU buy quote is confirmed, call the Aktionariat
requestPaymentInstructions endpoint to register the order and store the
response in a new aktionariatResponse column on transaction_request.
- Add PaymentInstructionsResponse DTO to replace Promise<any>
- Move Aktionariat order submission from TransactionRequestService
  into RealUnitService.confirmBuy()
- Add PUT /realunit/buy/:id/confirm endpoint
- Remove RealUnitBlockchainService dependency from TransactionRequestService
- Make confirmTransactionRequest accept optional aktionariatResponse param
@xlamn xlamn marked this pull request as draft February 13, 2026 11:11
@xlamn xlamn marked this pull request as ready for review February 13, 2026 11:11
@TaprootFreak TaprootFreak merged commit 4019401 into develop Feb 13, 2026
8 checks passed
@TaprootFreak TaprootFreak deleted the feat/realunit-price-aktionariat-api branch February 13, 2026 12:40
xlamn added a commit to DFXswiss/realunit-app that referenced this pull request Feb 13, 2026
with
DFXswiss/api#3188 (review)
another endpoint is used to confirm the pay payment
- update confirm payment path
- added available shares to dtos
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.

2 participants