xrpld
Loading...
Searching...
No Matches
VaultHelpers.h
1#pragma once
2
3#include <xrpl/ledger/ReadView.h>
4#include <xrpl/protocol/AccountID.h>
5#include <xrpl/protocol/STAmount.h>
6#include <xrpl/protocol/STLedgerEntry.h>
7
8#include <optional>
9
10namespace xrpl {
11
22[[nodiscard]] std::optional<STAmount>
23assetsToSharesDeposit(SLE::const_ref vault, SLE::const_ref issuance, STAmount const& assets);
24
35[[nodiscard]] std::optional<STAmount>
36sharesToAssetsDeposit(SLE::const_ref vault, SLE::const_ref issuance, STAmount const& shares);
37
39enum class TruncateShares : bool { No = false, Yes = true };
40
47enum class WaiveUnrealizedLoss : bool { No = false, Yes = true };
48
63[[nodiscard]] std::optional<STAmount>
65 SLE::const_ref vault,
66 SLE::const_ref issuance,
67 STAmount const& assets,
70
83[[nodiscard]] std::optional<STAmount>
85 SLE::const_ref vault,
86 SLE::const_ref issuance,
87 STAmount const& shares,
89
99[[nodiscard]] bool
100isSoleShareholder(ReadView const& view, AccountID const& account, SLE::const_ref issuance);
101
102} // namespace xrpl
std::shared_ptr< STLedgerEntry const > const & const_ref
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::optional< STAmount > assetsToSharesWithdraw(SLE::const_ref vault, SLE::const_ref issuance, STAmount const &assets, TruncateShares truncate=TruncateShares::No, WaiveUnrealizedLoss waive=WaiveUnrealizedLoss::No)
From the perspective of a vault, return the number of shares to demand from the depositor when they a...
std::optional< STAmount > sharesToAssetsWithdraw(SLE::const_ref vault, SLE::const_ref issuance, STAmount const &shares, WaiveUnrealizedLoss waive=WaiveUnrealizedLoss::No)
From the perspective of a vault, return the number of assets to give the depositor when they redeem a...
TruncateShares
Controls whether to truncate shares instead of rounding.
std::optional< STAmount > sharesToAssetsDeposit(SLE::const_ref vault, SLE::const_ref issuance, STAmount const &shares)
From the perspective of a vault, return the number of assets to take from depositor when they receive...
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
bool isSoleShareholder(ReadView const &view, AccountID const &account, SLE::const_ref issuance)
Returns true iff account holds all of the vault's outstanding shares — i.e.
std::optional< STAmount > assetsToSharesDeposit(SLE::const_ref vault, SLE::const_ref issuance, STAmount const &assets)
From the perspective of a vault, return the number of shares to give depositor when they offer a fixe...
WaiveUnrealizedLoss
Controls whether the withdraw conversion helpers (assetsToSharesWithdraw and sharesToAssetsWithdraw) ...