FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
transfer.hpp
Go to the documentation of this file.
1#pragma once
2// An internal transfer: an amount of one asset moved between two accounts of the same exchange
3// (the accounts of a pool, core/account_pool.hpp), as a connector that can do it carries it out
4// (venues::Venue::transfer, VenueCaps::internal_transfer) and the pool treasury asks for it
5// (core/treasury.hpp). Control path only: these types allocate.
6//
7// A transfer is named by `client_id`, unique per transfer and never reused: the venue is asked for
8// it under that id, and its state is asked for by that id after a timeout or a restart, so a
9// transfer whose answer was lost is looked up instead of sent twice.
12
13#include <cstdint>
14#include <string>
15#include <string_view>
16
17namespace fastmm {
18
19enum class TransferState : std::uint8_t {
20 Pending = 0, // the venue took it and has not finished it
21 Done = 1, // the amount has moved
22 Failed = 2, // the venue refused it or gave up: nothing moved
23 NotFound = 3, // the venue has no transfer under this id (status only)
24 Unknown = 4, // no usable answer (a transport error, a timeout, a 5xx): it may have happened
25};
26[[nodiscard]] constexpr std::string_view to_string(TransferState s) noexcept {
27 switch (s) {
29 return "pending";
31 return "done";
33 return "failed";
35 return "not_found";
37 return "unknown";
38 }
39 return "?";
40}
41
42struct TransferRequest {
43 std::string client_id; // [0-9a-z], at most kMaxClientId characters
44 VenueId from; // the pool account the amount leaves
45 VenueId to; // the pool account it goes to
46 // The venue's names of the two accounts (Venue::transfer_account(): a Binance sub-account's
47 // email, empty for the master account). Filled in by whoever hands the request to the venue.
48 std::string from_account;
49 std::string to_account;
50 std::string asset;
52 std::int64_t created_ms = 0; // wall clock; a venue's history query starts here
54 static constexpr std::size_t kMaxClientId = 30;
55};
57struct TransferResult {
59 std::string venue_ref; // the venue's id of the transfer (Binance tranId), when it gave one
60 std::string detail; // the venue's error or a description of the failure, for the log
61};
63} // namespace fastmm
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Definition strategy.hpp:16
@ Pending
orders on their way: sent, not yet working, or a requote waiting its turn
constexpr std::string_view to_string(ParamType t) noexcept
Definition params.hpp:63
TransferState
Definition transfer.hpp:21
@ Pending
the venue took it and has not finished it
@ NotFound
the venue has no transfer under this id (status only)
@ Unknown
no usable answer (a transport error, a timeout, a 5xx): it may have happened
@ Failed
the venue refused it or gave up: nothing moved
@ Done
the amount has moved
Strongly typed identifiers.
std::string client_id
[0-9a-z], at most kMaxClientId characters
Definition transfer.hpp:45
std::string asset
Definition transfer.hpp:52
static constexpr std::size_t kMaxClientId
Definition transfer.hpp:56
VenueId from
the pool account the amount leaves
Definition transfer.hpp:46
std::string to_account
Definition transfer.hpp:51
std::int64_t created_ms
wall clock; a venue's history query starts here
Definition transfer.hpp:54
std::string from_account
The venue's names of the two accounts (Venue::transfer_account(): a Binance sub-account's email,...
Definition transfer.hpp:50
VenueId to
the pool account it goes to
Definition transfer.hpp:47
Notional amount
Definition transfer.hpp:53
Definition transfer.hpp:59
std::string venue_ref
the venue's id of the transfer (Binance tranId), when it gave one
Definition transfer.hpp:61
TransferState state
Definition transfer.hpp:60
std::string detail
the venue's error or a description of the failure, for the log
Definition transfer.hpp:62