New HashMap can store both incoming and outgoing settlement proposals at the
same time and resulted in some code simplification, as there are less types
needed to convey the intention.
Provide a type alias for convenience (this also ensures that both binaries store
settlement proposals in the same way)
Opted not to implement an additional message to fetch a specific announcement from the Oracle actor because it would have made the oracle actor unnecessarily complex (We would have to split it into different functionality by trait).
The taker cfd actor holds a sliding window of all the announcements received from the oracle actor.
We can now pass more than one set of `nonce_pks` when creating a CFD.
Each set corresponds to (and is identified by) a different oracle
event, allowing us to construct CFDs which can be settled via oracle
attestation at more than one point in time.
We also remember the CET-event relationship in `CfdTransactions`. This
is needed so that we can select the correct CET when the oracle
attests to the outcome of an event. Additionally, we save the
`nonce_pks` to more easily verify the adaptor signatures.
By removing the onclick handler on the table row, clicking any button in the row does not fire the onclick handler of the row as well.
This has the effect that for expanding the row you need to click the expand button.
Red colour is best used for drawing attention to unusual things or marking a
hazardous action.
Sell positions on the maker side are an expected & common thing, so there is no
need for the sell positions to stand out.
Keep track of outgoing/incoming settlement proposals in a hashmap inside the CFD
rocket that is available as a Rocket state in order to derive correct CfdState
for the UI.
Add placeholders for actions for accepting/rejecting settlement offers in the maker.
Also:
- rename Accept/Reject in few places to reduce ambiguity between interacting
with an order and a settlement proposal.
- allow only one in-flight settlement proposal from the taker
CfdTable uses react-table which resets its state if the data sources changes. We don't want some state to reset, e.g. sorting and un-expanding because that will mess with the user if the table suddenly changes.
Note: it looks like that the provided types are missing this field. It's been tested and it works as expected but we need to @ts-ignore because tsc would complain.
* Offer price based on current price
To keep it simple we set the offer price to current price + 3% spread if we have a current price and the offer's initial value is 0.
This. means we cannot set the offer price to 0 anymore, but that is OK.
Additionally, there is a refresh button so the maker can refresh the offer price (no auto-refresh for now).
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
For calculating the Profit/Loss in BTC we use a simple forumla:
- for long: `profit_btc = quantity_usd * ((1/initial_price)-(1/current_price))`.
- for short: `profit_btc = quantity_usd * ((1/current_price)-(1/initial_price))`.
We round the p/l to 6 decimal points in the UI.
P/L is easier to understand in percent. For the UI we round to 2 decimal points.
We also stopped generating random oracle-related values for the
protocol tests, greatly simplifying the test suite. This has the
side-effect that we no longer verify that _all_ CETs can be unlocked.
Re-introducing random oracle-related data in the future should be
considered.
Previously we only returned the new state, but we also have to set it internally, otherwise the cfd might be out of date.
This was a problem when getting the refund transaction from the cfd directly after a state transition to `MustRefund`.
The cfd instance had not actually transitioned to the new state, even though it was saved in the database.