Price
public final class Price : Decodable, Sendable
extension Price: Equatable
Represents Price. Price in Stellar is represented as a fraction.
-
Numerator.
Declaration
Swift
public final let n: Int32 -
Denominator.
Declaration
Swift
public final let d: Int32 -
Create a new price. Price in Stellar is represented as a fraction. E.g. Price of 1 unit of selling in terms of buying. For example, if you wanted to sell 30 XLM and buy 5 BTC, the price would be {numerator, denominator} = {5,30}.
Declaration
Swift
public init(numerator: Int32, denominator: Int32)Parameters
numeratornumerator
denominatordenominator
-
Approximates ‘price’ to a fraction. Please remember that this function can give unexpected results for values that cannot be represented as a fraction with 32-bit numerator and denominator. It’s safer to create a Price object using the constructor.
Declaration
Swift
public static func fromString(price: String) -> PriceParameters
priceE.g. “1.25”
-
Generates a PriceXDR object from the current Price object.
Declaration
Swift
public func toXdr() -> PriceXDR -
Initializer - creates a new instance by decoding from the given decoder.
Declaration
Swift
public required init(from decoder: Decoder) throwsParameters
decoderThe decoder containing the data
-
Declaration
Swift
public static func == (lhs: Price, rhs: Price) -> Bool
View on GitHub
Install in Dash