Class DexSnapshot
The ledger state an OfferCreate crosses against: the offers in the books it can
reach, the AMM pools on those books, and what the accounts involved hold. A crossing
computed by OfferCreateCrossing is exact against this state; it is only as
current as the state is.
Inheritance
Namespace: Xrpl.Amounts
Assembly: Xrpl.dll
Syntax
public sealed class DexSnapshot
Remarks
FromNodeAsync reads everything from a node. A snapshot built by hand must list
every offer of each book it covers, in book order - as book_offers returns them -
and every account whose balance the crossing reads: the taker, each offer's owner, and
each issuer with a transfer rate or tick size. An MPT the transaction trades or moves needs
its issuance in MptIssuances, and those accounts' MPTokens of it in
MptHoldings. A book read only in part goes in PartialBooks. For a transaction in a permissioned domain, the domain and the
credentials that decide its members go in Domains and
Credentials; where a hybrid offer shares a quality with domain offers, the
offers are listed in the order they were placed.
A snapshot keeps its own copy of each list it is given, so changing a list afterwards does not change the snapshot. The engine indexes a snapshot on its first evaluation and reuses that index for every later one against the same instance.
Fields
| Edit this page View SourceUnlimitedTaker
An address to quote with before a wallet is connected: as the account of an
OfferCreate or the source of a Payment, FromNodeAsync reads nothing
for it and gives it unlimited funds of what it pays and room for what it receives.
It is ACCOUNT_ONE, which no key controls, so no real account ever has it.
Declaration
public const string UnlimitedTaker = "rrrrrrrrrrrrrrrrrrrrBZbvji"
Field Value
| Type | Description |
|---|---|
| string |
Properties
| Edit this page View SourceAccounts
The accounts the crossing reads.
Declaration
public IReadOnlyList<DexAccount> Accounts { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexAccount> |
ApproximatedOwners
The offer owners whose account and trust lines were not read but built from what
book_offers reports of their funds (OwnerFundsFromBook).
A result that crosses their offers is exact as far as their funds go; see the option
for what it leaves out.
Declaration
public IReadOnlyList<string> ApproximatedOwners { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Credentials
The credentials the transaction reads: those a domain accepts, held by the accounts
whose membership is checked, and those a payment names in CredentialIDs.
Declaration
public IReadOnlyList<DexCredential> Credentials { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexCredential> |
Domains
The permissioned domains whose books the transaction walks, or whose membership it checks.
Declaration
public IReadOnlyList<DexDomain> Domains { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexDomain> |
LedgerSequence
The sequence of the ledger the snapshot was read at; 0 for one built by hand. A deeper read of the same books can be made at it with Ledger.
Declaration
public uint LedgerSequence { get; init; }
Property Value
| Type | Description |
|---|---|
| uint |
MptHoldings
The MPT holdings (MPToken) the transaction reads: the taker's or sender's, the
destination's, each offer owner's of what its offer gives and asks for, and each pool's.
An account with no holding listed holds none, and gets one when an offer pays it the MPT.
Declaration
public IReadOnlyList<DexMptHolding> MptHoldings { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexMptHolding> |
MptIssuances
The MPT issuances the transaction trades or moves (MPTokenIssuance): how much is
outstanding, the most there may be, the transfer fee, and the flags that let it trade.
Declaration
public IReadOnlyList<DexMptIssuance> MptIssuances { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexMptIssuance> |
Offers
The offers of the books the crossing can reach, each book in book order.
Declaration
public IReadOnlyList<DexOffer> Offers { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexOffer> |
ParentCloseTime
The close time of the ledger before the one the transaction lands in, in seconds since
the Ripple epoch. An offer whose Expiration is not after it is removed, not crossed.
Declaration
public uint ParentCloseTime { get; init; }
Property Value
| Type | Description |
|---|---|
| uint |
PartialBooks
The books whose offers the snapshot holds only in part: their first offers, the rest
left unread. A result that walked past the last of them says so in its
NeedsDeeperBooks.
Declaration
public IReadOnlyList<DexBook> PartialBooks { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexBook> |
Pools
The AMM pools on those books.
Declaration
public IReadOnlyList<DexAmmPool> Pools { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexAmmPool> |
ReserveBase
The account reserve, in drops.
Declaration
public ulong ReserveBase { get; init; }
Property Value
| Type | Description |
|---|---|
| ulong |
ReserveIncrement
The reserve per owned object, in drops.
Declaration
public ulong ReserveIncrement { get; init; }
Property Value
| Type | Description |
|---|---|
| ulong |
TrustLines
The trust lines the transaction reads, each listed once from one of its two accounts,
with the other account's settings in the Peer properties.
Declaration
public IReadOnlyList<DexTrustLine> TrustLines { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<DexTrustLine> |
Methods
| Edit this page View SourceFromNodeAsync(IXrplClient, string, IssuedCurrency, IssuedCurrency, DexSnapshotOptions, CancellationToken)
Reads from a node, at one ledger (the last validated one unless Ledger names another), everything an OfferCreate by
account trading takerGets for
takerPays can reach: the book it crosses, the two books of the
bridge through XRP when neither side is XRP, the AMM pools on them, and the accounts
and trust lines the crossing reads.
Declaration
public static Task<DexSnapshot> FromNodeAsync(IXrplClient client, string account, Common.IssuedCurrency takerPays, Common.IssuedCurrency takerGets, DexSnapshotOptions options = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IXrplClient | client | The node to read from. |
| string | account | The account placing the offer. |
| Common.IssuedCurrency | takerPays | The asset the offer asks for. |
| Common.IssuedCurrency | takerGets | The asset the offer gives. |
| DexSnapshotOptions | options | How deep to read the books, and at which ledger; one page each, at the last validated ledger, when null. |
| CancellationToken | cancellationToken | Cancels the reads. |
Returns
| Type | Description |
|---|---|
| Task<DexSnapshot> |
Remarks
Without BookDepth, each book is read with one
book_offers request: the offers whose owner holds nothing are left out, except
the account's own, and a book deeper than one page is listed in
PartialBooks. The transaction lands in a later ledger, whose state may differ.
FromNodeAsync(IXrplClient, OfferCreate, DexSnapshotOptions, CancellationToken)
Reads from a node, at one ledger (the last validated one unless Ledger names another), everything offer can
reach: the books it crosses - its domain's when it names one - the AMM pools on the open
ones, the accounts and trust lines the crossing reads, the offer OfferSequence
cancels, and the domain with the credentials that decide who is in it.
Declaration
public static Task<DexSnapshot> FromNodeAsync(IXrplClient client, OfferCreate offer, DexSnapshotOptions options = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IXrplClient | client | The node to read from. |
| OfferCreate | offer | The transaction. |
| DexSnapshotOptions | options | How deep to read the books, and at which ledger; one page each, at the last validated ledger, when null. |
| CancellationToken | cancellationToken | Cancels the reads. |
Returns
| Type | Description |
|---|---|
| Task<DexSnapshot> |
Remarks
As the other overload, for the books.
FromNodeAsync(IXrplClient, Payment, DexSnapshotOptions, CancellationToken)
Reads from a node, at one ledger (the last validated one unless Ledger names another), everything payment can
reach: the trust lines along its paths and its default path, the books on them - its
domain's when it names one - with the AMM pools on the open ones, the accounts involved
with the destination's deposit preauthorizations, the credentials it presents, and the
domain with the credentials that decide who is in it.
Declaration
public static Task<DexSnapshot> FromNodeAsync(IXrplClient client, Payment payment, DexSnapshotOptions options = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IXrplClient | client | The node to read from. |
| Payment | payment | The payment, with its paths as |
| DexSnapshotOptions | options | How deep to read the books, and at which ledger; one page each, at the last validated ledger, when null. |
| CancellationToken | cancellationToken | Cancels the reads. |
Returns
| Type | Description |
|---|---|
| Task<DexSnapshot> |
Remarks
Without BookDepth, each book is read with one
book_offers request: the offers whose owner holds nothing are left out, except
the sender's own, and a book deeper than one page is listed in PartialBooks.
The transaction lands in a later ledger, whose state may differ.
WithoutOffer(string)
The snapshot without the offer offerIndex: the same entries with
that offer left out of Offers, as building the snapshot by hand without
it would give. Use it for an OfferCancel, which the engine does not evaluate, or
to take out the offer an OfferCreate placed (its index is
Hashes.HashOfferId of the account and the sequence or ticket it used).
Declaration
public DexSnapshot WithoutOffer(string offerIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | offerIndex | The offer's ledger index, in either case. |
Returns
| Type | Description |
|---|---|
| DexSnapshot | A new snapshot whose index is derived from this one's, so evaluating against it costs no index build; this snapshot itself when it holds no such offer. |
Remarks
Only the offer is removed, whoever owns it. Nothing else changes: not the owner's
OwnerCount, which deleting the offer on the ledger lowers by one (see the
overload with releaseOwnerReserve), not the Sequence of the account that
cancels it, and no fee is charged.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | This snapshot lists a trust line or an MPT holding twice, or a hybrid offer names no domain. |
WithoutOffer(string, bool)
The snapshot without the offer offerIndex, as
WithoutOffer(string), and with the offer's reserve released when
releaseOwnerReserve is set: the owner's OwnerCount one lower,
as offerDelete leaves it. Set it for an OfferCancel, and for the remainder
a SnapshotAfter counted in the owner's OwnerCount when it placed it.
Declaration
public DexSnapshot WithoutOffer(string offerIndex, bool releaseOwnerReserve)
Parameters
| Type | Name | Description |
|---|---|---|
| string | offerIndex | The offer's ledger index, in either case. |
| bool | releaseOwnerReserve | Whether the owner's |
Returns
| Type | Description |
|---|---|
| DexSnapshot | A new snapshot whose index is derived from this one's, the owner's account included; this snapshot itself when it holds no such offer. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | This snapshot lists a trust line or an MPT holding twice, or a hybrid offer names no domain. |