Class VaultShares
Vault deposits and withdrawals computed offline from the Vault entry and its share
issuance, the way rippled's VaultDeposit, VaultWithdraw and
VaultHelpers.cpp compute them.
Inheritance
Namespace: Xrpl.Sugar
Assembly: Xrpl.dll
Syntax
public static class VaultShares
Remarks
Repeated here is everything that depends on the amounts: the conversion between assets and
shares, the rounding to the vault's scale, and the refusals it leads to - a deposit or
withdrawal too small to move a share or a representable amount (tecPRECISION_LOSS),
the vault's available assets or the holder's shares (tecINSUFFICIENT_FUNDS), and
AssetsMaximum (tecLIMIT_EXCEEDED), and, given the parent close time, the phase
of a closed-ended vault (PhaseAt(LOVault, DateTime?, LedgerRules)). Authorization, freezes and the account's own
funds are not; PreviewVaultDeposit(IXrplClient, VaultDeposit, CancellationToken) and
PreviewVaultWithdraw(IXrplClient, VaultWithdraw, CancellationToken) cover them.
The share count comes from the share issuance: OutstandingAmount of the
MPTokenIssuance whose ID is the vault's ShareMPTID.
Methods
| Edit this page View SourceDeposit(LOVault, ulong, XrplNumber, XrplNumber?, LedgerRules, DateTime?)
A VaultDeposit of amount: the shares minted and the assets
the vault takes, which can be less than the amount.
Declaration
public static VaultQuote Deposit(LOVault vault, ulong sharesOutstanding, XrplNumber amount, XrplNumber? depositorBalance = null, LedgerRules rules = null, DateTime? parentCloseTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOVault | vault | The |
| ulong | sharesOutstanding | The share issuance's |
| XrplNumber | amount | The deposit, in the vault asset's unit. |
| Nullable | depositorBalance | The depositor's balance of an issued-currency asset, for the check that the deposit changes it at all; null skips that check. Not used for XRP and MPT. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the phases of a closed-ended vault; null skips that check. A local time is converted to UTC; an unspecified one is taken as UTC. |
Returns
| Type | Description |
|---|---|
| VaultQuote |
Exceptions
| Type | Condition |
|---|---|
| OverflowException | An amount is beyond decimal. |
PhaseAt(LOVault, DateTime?, LedgerRules)
The phase of a closed-ended vault at parentCloseTime, as rippled's
getVaultPhase decides it: subscription up to and including SubscriptionDate,
investment until RedemptionDate, redemption from it on. A vault without a
SubscriptionDate is always in its subscription phase, and one without a
RedemptionDate never leaves its investment phase.
Declaration
public static VaultPhase PhaseAt(LOVault vault, DateTime? parentCloseTime, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOVault | vault | The |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in. A local time is converted to UTC; an unspecified one is taken as UTC. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
Returns
| Type | Description |
|---|---|
| VaultPhase |
Remarks
None means no phase restricts deposits or withdrawals: the vault
is not closed-ended, no time is given, or LendingProtocolV1_1, the amendment that
enforces the phases, is not enabled. These are the phases Deposit(LOVault, ulong, XrplNumber, XrplNumber?, LedgerRules, DateTime?),
WithdrawAssets(LOVault, ulong, ulong, XrplNumber, LedgerRules, DateTime?) and RedeemShares(LOVault, ulong, ulong, ulong, LedgerRules, DateTime?) refuse by: a deposit only in
Subscription, a withdrawal not in
Investment.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
RedeemShares(LOVault, ulong, ulong, ulong, uint, LedgerRules, DateTime?)
A VaultWithdraw of shares vault shares that pays a transfer
fee: the fee comes out of what the shares pay (AssetsDelivered).
Declaration
public static VaultQuote RedeemShares(LOVault vault, ulong sharesOutstanding, ulong holderShares, ulong shares, uint transferRate, LedgerRules rules = null, DateTime? parentCloseTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOVault | vault | The |
| ulong | sharesOutstanding | The share issuance's |
| ulong | holderShares | The withdrawing account's shares. |
| ulong | shares | The shares to redeem. |
| uint | transferRate | The rate the withdrawal pays in billionths, as WithdrawalTransferRate(IssuedCurrency, string, string, uint, LedgerRules)
returns it; 1,000,000,000 or 0 for no fee. Ignored before |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the phases of a closed-ended vault; null skips that check. A local time is converted to UTC; an unspecified one is taken as UTC. |
Returns
| Type | Description |
|---|---|
| VaultQuote |
Exceptions
| Type | Condition |
|---|---|
| OverflowException | An amount is beyond decimal. |
| ArgumentOutOfRangeException |
|
RedeemShares(LOVault, ulong, ulong, ulong, LedgerRules, DateTime?)
A VaultWithdraw of shares vault shares: the assets they pay out.
Declaration
public static VaultQuote RedeemShares(LOVault vault, ulong sharesOutstanding, ulong holderShares, ulong shares, LedgerRules rules = null, DateTime? parentCloseTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOVault | vault | The |
| ulong | sharesOutstanding | The share issuance's |
| ulong | holderShares | The withdrawing account's shares. |
| ulong | shares | The shares to redeem. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the phases of a closed-ended vault; null skips that check. A local time is converted to UTC; an unspecified one is taken as UTC. |
Returns
| Type | Description |
|---|---|
| VaultQuote |
Exceptions
| Type | Condition |
|---|---|
| OverflowException | An amount is beyond decimal. |
WithdrawAssets(LOVault, ulong, ulong, XrplNumber, uint, LedgerRules, DateTime?)
A VaultWithdraw of amount in the vault asset that pays a
transfer fee: the vault pays out the amount plus the fee, so the destination receives
the amount (AssetsDelivered).
Declaration
public static VaultQuote WithdrawAssets(LOVault vault, ulong sharesOutstanding, ulong holderShares, XrplNumber amount, uint transferRate, LedgerRules rules = null, DateTime? parentCloseTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOVault | vault | The |
| ulong | sharesOutstanding | The share issuance's |
| ulong | holderShares | The withdrawing account's shares. |
| XrplNumber | amount | The assets the destination is to receive. |
| uint | transferRate | The rate the withdrawal pays in billionths, as WithdrawalTransferRate(IssuedCurrency, string, string, uint, LedgerRules)
returns it; 1,000,000,000 or 0 for no fee. Ignored before |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the phases of a closed-ended vault; null skips that check. A local time is converted to UTC; an unspecified one is taken as UTC. |
Returns
| Type | Description |
|---|---|
| VaultQuote |
Exceptions
| Type | Condition |
|---|---|
| OverflowException | An amount is beyond decimal. |
| ArgumentOutOfRangeException |
|
WithdrawAssets(LOVault, ulong, ulong, XrplNumber, LedgerRules, DateTime?)
A VaultWithdraw of amount in the vault asset: the shares burned
and the assets paid out.
Declaration
public static VaultQuote WithdrawAssets(LOVault vault, ulong sharesOutstanding, ulong holderShares, XrplNumber amount, LedgerRules rules = null, DateTime? parentCloseTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| LOVault | vault | The |
| ulong | sharesOutstanding | The share issuance's |
| ulong | holderShares | The withdrawing account's shares. |
| XrplNumber | amount | The assets to withdraw. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
| Nullable | parentCloseTime | The close time of the ledger before the one the transaction lands in, for the phases of a closed-ended vault; null skips that check. A local time is converted to UTC; an unspecified one is taken as UTC. |
Returns
| Type | Description |
|---|---|
| VaultQuote |
Exceptions
| Type | Condition |
|---|---|
| OverflowException | An amount is beyond decimal. |
WithdrawalTransferRate(IssuedCurrency, string, string, uint, LedgerRules)
withdrawalTransferRate: the transfer rate a VaultWithdraw pays. Under
fixCleanup3_5_0 it is the asset's rate when a holder other than the issuer
withdraws to another account that is not the issuer either; otherwise, and always
before the amendment and for XRP, there is no fee.
Declaration
public static uint WithdrawalTransferRate(Common.IssuedCurrency asset, string account, string destination, uint assetTransferRate, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Common.IssuedCurrency | asset | The vault asset. |
| string | account | The withdrawing account. |
| string | destination | The |
| uint | assetTransferRate | The asset's transfer rate in billionths: the issuer's |
| LedgerRules | rules | The amendments in force; the current rules when null. |
Returns
| Type | Description |
|---|---|
| uint | The rate in billionths, 1,000,000,000 for no fee. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|