Class OfferCrossing
What one offer contributes when a payment or an OfferCreate crosses it, sized the
way rippled's BookStep sizes it: the offer's funding, transfer fees in and out, and
the cut to an input or output limit, each rounded as the node rounds it.
Inheritance
Namespace: Xrpl.Amounts
Assembly: Xrpl.dll
Syntax
public static class OfferCrossing
Remarks
A step starts from Fund(XrplQuality, XrplAmount, XrplAmount, XrplAmount?, uint, uint, LedgerRules), which applies the transfer rates and what the offer's
owner can actually pay. LimitStepIn(OfferStep, XrplAmount, LedgerRules) and LimitStepOut(OfferStep, XrplAmount, LedgerRules) then cut it
to what the rest of the path allows, as BookStep's forward and reverse passes do.
PassesQualityLimit(XrplAmount, XrplAmount, XrplQuality, bool, LedgerRules) is the check a strand's result must pass against the
taker's limit quality.
The offer is crossed at the quality of its book directory (FromBookDirectory(string)), set when it was placed, not at the ratio of what it has left.
Fields
| Edit this page View SourceQualityOne
A transfer rate of 1: no fee (QUALITY_ONE).
Declaration
public const uint QualityOne = 1000000000
Field Value
| Type | Description |
|---|---|
| uint |
Methods
| Edit this page View SourceCross(OfferStep, XrplAmount, XrplAmount, LedgerRules)
What crossing one offer delivers when a taker asks for deliver and
pays at most sendMax: the reverse pass sizes the step to the output,
the forward pass runs from the input that needs (capped at sendMax),
as a strand made of this one book step is run.
Declaration
public static OfferStep Cross(OfferStep funded, XrplAmount deliver, XrplAmount sendMax, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| OfferStep | funded | The offer's step from Fund(XrplQuality, XrplAmount, XrplAmount, XrplAmount?, uint, uint, LedgerRules). |
| XrplAmount | deliver | The most the taker asks for. |
| XrplAmount | sendMax | The most the taker pays. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
Returns
| Type | Description |
|---|---|
| OfferStep |
ForwardPass(OfferStep, XrplAmount, OfferStep, LedgerRules)
The forward pass over one offer, BookStep::fwdImp: the step fed
input, cut with LimitStepIn(OfferStep, XrplAmount, LedgerRules) when that is less than the
offer takes. When the result delivers more than the reverse pass asked for on no more
input, the node recomputes the input for the reverse pass's output and, if it is the
same, settles on that output - so a crossing delivers exactly what was asked for.
Declaration
public static OfferStep ForwardPass(OfferStep funded, XrplAmount input, OfferStep reverse, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| OfferStep | funded | The offer's step from Fund(XrplQuality, XrplAmount, XrplAmount, XrplAmount?, uint, uint, LedgerRules). |
| XrplAmount | input | What reaches the step on the forward pass. |
| OfferStep | reverse | The same offer's step from the reverse pass. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
Returns
| Type | Description |
|---|---|
| OfferStep |
Fund(XrplQuality, XrplAmount, XrplAmount, XrplAmount?, uint, uint, LedgerRules)
What an offer can contribute before any limit: BookStep::forEachOffer. The input
carries the transfer fee on the way in; the owner pays the fee on the way out, and an
owner with less than that is cut to what they hold.
Declaration
public static OfferStep Fund(XrplQuality quality, XrplAmount offerIn, XrplAmount offerOut, XrplAmount? ownerFunds, uint transferRateIn = 1000000000, uint transferRateOut = 1000000000, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XrplQuality | quality | The offer's quality, from its book directory. |
| XrplAmount | offerIn | What the offer takes: its |
| XrplAmount | offerOut | What the offer gives: its |
| XrplAmount? | ownerFunds | What the owner holds of the output asset; null when the owner issues it, and so has unlimited funds. |
| uint | transferRateIn | The input's transfer rate, when the previous step redeems; otherwise QualityOne. |
| uint | transferRateOut | The output's transfer rate, when the owner pays it; otherwise QualityOne. |
| LedgerRules | rules | The amendments in force; the current rules when null. |
Returns
| Type | Description |
|---|---|
| OfferStep |
LimitIn(XrplQuality, XrplAmount, XrplAmount, XrplAmount, bool, LedgerRules)
TOffer::limitIn: the offer cut to take at most limit, with
ceilInStrict under fixReducedOffersV2 and ceilIn before it.
Declaration
public static (XrplAmount In, XrplAmount Out) LimitIn(XrplQuality quality, XrplAmount offerIn, XrplAmount offerOut, XrplAmount limit, bool roundUp, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XrplQuality | quality | |
| XrplAmount | offerIn | |
| XrplAmount | offerOut | |
| XrplAmount | limit | |
| bool | roundUp | |
| LedgerRules | rules |
Returns
| Type | Description |
|---|---|
| (XrplAmount In, XrplAmount Out) |
LimitOut(XrplQuality, XrplAmount, XrplAmount, XrplAmount, bool, LedgerRules)
TOffer::limitOut: the offer cut to give at most limit, with ceilOutStrict.
Declaration
public static (XrplAmount In, XrplAmount Out) LimitOut(XrplQuality quality, XrplAmount offerIn, XrplAmount offerOut, XrplAmount limit, bool roundUp, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XrplQuality | quality | |
| XrplAmount | offerIn | |
| XrplAmount | offerOut | |
| XrplAmount | limit | |
| bool | roundUp | |
| LedgerRules | rules |
Returns
| Type | Description |
|---|---|
| (XrplAmount In, XrplAmount Out) |
LimitStepIn(OfferStep, XrplAmount, LedgerRules)
limitStepIn: the step cut to take at most limit, the offer's
share found with LimitIn(XrplQuality, XrplAmount, XrplAmount, XrplAmount, bool, LedgerRules) rounded down, as the forward pass does.
Declaration
public static OfferStep LimitStepIn(OfferStep step, XrplAmount limit, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| OfferStep | step | |
| XrplAmount | limit | |
| LedgerRules | rules |
Returns
| Type | Description |
|---|---|
| OfferStep |
LimitStepOut(OfferStep, XrplAmount, LedgerRules)
limitStepOut: the step cut to give at most limit, the offer's
share found with LimitOut(XrplQuality, XrplAmount, XrplAmount, XrplAmount, bool, LedgerRules) rounded up, as the reverse pass does.
Declaration
public static OfferStep LimitStepOut(OfferStep step, XrplAmount limit, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| OfferStep | step | |
| XrplAmount | limit | |
| LedgerRules | rules |
Returns
| Type | Description |
|---|---|
| OfferStep |
MulRatio(XrplAmount, uint, uint, bool, LedgerRules)
mulRatio(amount, num, den, roundUp): the amount times num / den, as the
typed amounts compute it - exact with a directed last unit for XRP and MPT, a 64-bit
mantissa with the remainder deciding the last unit for an issued currency.
Declaration
public static XrplAmount MulRatio(XrplAmount amount, uint num, uint den, bool roundUp, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XrplAmount | amount | |
| uint | num | |
| uint | den | |
| bool | roundUp | |
| LedgerRules | rules |
Returns
| Type | Description |
|---|---|
| XrplAmount |
Exceptions
| Type | Condition |
|---|---|
| DivideByZeroException |
|
| OverflowException | The result is beyond what the asset can hold. |
PassesQualityLimit(XrplAmount, XrplAmount, XrplQuality, bool, LedgerRules)
The check a strand's result must pass: its quality, Quality(out, in), no worse
than limitQuality - or, when the requested output was adjusted to
reach that quality, within a relative 10^-7 of it.
Declaration
public static bool PassesQualityLimit(XrplAmount stepIn, XrplAmount stepOut, XrplQuality limitQuality, bool adjustedRemainingOut = false, LedgerRules rules = null)
Parameters
| Type | Name | Description |
|---|---|---|
| XrplAmount | stepIn | |
| XrplAmount | stepOut | |
| XrplQuality | limitQuality | |
| bool | adjustedRemainingOut | |
| LedgerRules | rules |
Returns
| Type | Description |
|---|---|
| bool |