Invoke user actions (cfd actions & taking an order) synchronously in
order to be able to communicate the results.
Use HttpApiProblem to send error details to the frontend in a standard way.
Invoke user actions (cfd actions & posting a new sell order) synchronously in
order to be able to communicate the results.
Use HttpApiProblem to send error details to the frontend in a standard way.
Withdraw is an optional subcommand of the network subcommand, so the command reads like this, e.g. taker:
`./taker mainnet withdraw --address ...`
Internally, we use the wallet actor for withdrawing for now (simplifies the implementation, otherwise we would have to extract the wallet construction outside the actor).
Fee rate can either be passed by user or is set to default fee rate of `1.0`.
We enable RBF (replace by fee) signalling so that users can bump the transaction fee.
This allows opting-in for longer-running tests by enabling "expensive_tests"
feature, instead of waiting for a few minutes after starting `cargo test`.
Amend the CI to run all the tests (including expensive ones) on every run.
Mockall is a mocking framework that removes the need for writing more actors,
making tests easier to write.
Summary:
- add one more layer of indirection (a trait per actor type: Wallet, Oracle, Monitor)
- Mocks implementing the actor traits (with default stubbed implementations if no extra
behaviour needed)
- references to the mocks are being passed into the tests (via Arc<Mutex>>), allowing
for dynamically changing the behaviour and adding assertions. This also
aids readability, as the mock setup can be collocated with a particular
test, if the test needs something extra
Fixes#450
The which do not fit into the 65535 byte message size
limit of the noise protocol are chunked before
encryption. This feature was introduced to handle the
very large messages which contained the CET's.
More research is required into the NOISE_PARAMS and
whether they can be used to configure snow elegantly
handle authentication.
Create newtypes for Price and Usd that are sent to the UI with 2 digits precision.
Store and send higher precision prices between maker and taker; currently 24
digits, it can be changed with one constant.
Round percents visible in the UI to single digit.
Created new Timestamp struct that only uses seconds (as i64 in order
to play nice with both sqlx and chrono) and removed use of SytemTime::now()
throughout in the process.
This PR addresses #352 but also had the effect of doing a better job of
addressing #434, making #435 pointless.
Stumbled on this when writing actor tests.
We cannot create a failing test for this code at the moment, because our current test framework does not allow us to test at this granulairty level.
Nevertheless, we should fix this.
Rational:
If the maker is unable to contact the taker about the contract setup we fail now (previously we tried to continue).
This means, that we should only transition the maker's cfd to the new state if we are able to contact the maker.
Addresses #357 and #365. Although not a very large change, this PR ends up touching rather a lot of code.
* Converted types `Usd`, `Leverage` and `Percent` to something that is appropriate to this application
* Created new types `Price` and `InversePrice` to use for BTC/USD exchange rate with appropriate algebraic ops implemented as well.
* Added new positive tests
* The function `daemon::model::calculate_profit()` has been changed substantially as the updated types make the existing workflow needlessly complex
* Some tests (mostly in `cfd.rs` required updating) in order to make use of the new types.
* Minor edit to `.gitignore` to avoid accidental pushing of DB to repository--should have been it's own item, added here to fix a problem that arose during this work.
NOTE:
* There may be an excess of algebraic ops implemented, some pruning may be appropriate.
Fetching new events all over the place is cumbersome and it is likely that we will forget about doing so (e.g. atm we forgot doing this when receiving a roll-over request at the maker). Hence, we now fetch on a regular interval for a fixed timespan:
When starting up we fetch oracle events for the next 24h. Afterwards we check every 5 minutes again if there is a new event to check. This should ensure that we always know about needed events.
Include a generic Wallet actor constructor in the actor systems and allow
passing in a generic Wallet actor implementing xtra::Handlers into the cfd
actors.
Rename 'Maker' and 'Taker' to 'MakerActorSystem' and 'TakerActorSystem' for
readability.
Co-authored-by: Mariusz Klochowicz <mariusz@klochowicz.com>
This allows us to avoid the use of the constant in two places which
removes the dependency on the constant from the taker entirely.
The logic here is generally not great - in particular having the taker
anticipate, which announcement it is going to be - but this is the
least invasive way of making the term dynamic.