AmountMath: { add: (<A>(leftAmount: A,
rightAmount: A,
brand??: Brand) => A); coerce: (<A>(brand: Brand,
allegedAmount: A) => A); getValue: (<A>(brand: Brand,
amount: A) => A["value"]); isEmpty: ((amount: Amount,
brand??: Brand) => boolean); isEqual: (<A>(leftAmount: A,
rightAmount: A,
brand??: Brand) => boolean); isGTE: (<K>(leftAmount: Amount<K>,
rightAmount: Amount<K>,
brand??: Brand<K>) => boolean); make: (<B, V>(brand: B,
allegedValue: V) => B extends Brand<"nat"> ? NatAmount : V extends bigint ? NatAmount : V extends CopySet ? CopySetAmount<V<V>["payload"][0]> : V extends CopyBag ? CopyBagAmount<V<(...
)>["payload"][0][0]> : V extends SetValue ? SetAmount<V<V>[0]> : never); makeEmpty: { (brand: Brand): NatAmount; <K>(brand: Brand<K>,
assetKind: K): Amount<K>; }; makeEmptyFromAmount: (<A>(amount: A) => A); max: (<A>(x: A,
y: A,
brand??: Brand) => A); min: (<A>(x: A,
y: A,
brand??: Brand) => A); subtract: (<L, R>(leftAmount: L,
rightAmount: R,
brand??: Brand) => L extends R ? L<L> : never); } = ... Type declaration
add: (<A>(leftAmount: A, rightAmount: A, brand??: Brand) => A)
- <A>(leftAmount, rightAmount, brand?): A
Parameters
- leftAmount: A
- rightAmount: A
Optional
brand: Brand = undefined
Returns A
coerce: (<A>(brand: Brand, allegedAmount: A) => A)
- <A>(brand, allegedAmount): A
Parameters
- brand: Brand
- allegedAmount: A
Returns A
getValue: (<A>(brand: Brand, amount: A) => A["value"])
- <A>(brand, amount): A["value"]
Returns A["value"]
isEmpty: ((amount: Amount, brand??: Brand) => boolean)
- (amount, brand?): boolean
Parameters
- amount: Amount
Optional
brand: Brand = undefined
Returns boolean
isEqual: (<A>(leftAmount: A, rightAmount: A, brand??: Brand) => boolean)
- <A>(leftAmount, rightAmount, brand?): boolean
Parameters
- leftAmount: A
- rightAmount: A
Optional
brand: Brand = undefined
Returns boolean
isGTE: (<K>(leftAmount: Amount<K>, rightAmount: Amount<K>, brand??: Brand<K>) => boolean)
- <K>(leftAmount, rightAmount, brand?): boolean
Parameters
- leftAmount: Amount<K>
- rightAmount: Amount<K>
Optional
brand: Brand<K> = undefined
Returns boolean
make: (<B, V>(brand: B, allegedValue: V) => B extends Brand<"nat">
? NatAmount
: V extends bigint
? NatAmount
: V extends CopySet
? CopySetAmount<V<V>["payload"][0]>
: V extends CopyBag
? CopyBagAmount<V<(...)>["payload"][0][0]>
: V extends SetValue
? SetAmount<V<V>[0]>
: never)
- <B, V>(brand, allegedValue): B extends Brand<"nat">
? NatAmount
: V extends bigint
? NatAmount
: V extends CopySet
? CopySetAmount<V<V>["payload"][0]>
: V extends CopyBag
? CopyBagAmount<V<(...)>["payload"][0][0]>
: V extends SetValue
? SetAmount<V<V>[0]>
: never Type Parameters
- B extends Brand
- V extends
| bigint
| CopySet
| SetValue
| CopyBag
Returns B extends Brand<"nat">
? NatAmount
: V extends bigint
? NatAmount
: V extends CopySet
? CopySetAmount<V<V>["payload"][0]>
: V extends CopyBag
? CopyBagAmount<V<(...)>["payload"][0][0]>
: V extends SetValue
? SetAmount<V<V>[0]>
: never
makeEmpty: {
(brand: Brand): NatAmount;
<K>(brand: Brand<K>, assetKind: K): Amount<K>;
}
- (brand): NatAmount
Returns NatAmount
- <K>(brand, assetKind): Amount<K>
Parameters
- brand: Brand<K>
- assetKind: K
Returns Amount<K>
makeEmptyFromAmount: (<A>(amount: A) => A)
max: (<A>(x: A, y: A, brand??: Brand) => A)
- <A>(x, y, brand?): A
Parameters
- x: A
- y: A
Optional
brand: Brand = undefined
Returns A
min: (<A>(x: A, y: A, brand??: Brand) => A)
- <A>(x, y, brand?): A
Parameters
- x: A
- y: A
Optional
brand: Brand = undefined
Returns A
subtract: (<L, R>(leftAmount: L, rightAmount: R, brand??: Brand) => L extends R
? L<L>
: never)
- <L, R>(leftAmount, rightAmount, brand?): L extends R
? L<L>
: never Type Parameters
- L extends Amount
- R extends Amount
Parameters
- leftAmount: L
- rightAmount: R
Optional
brand: Brand = undefined
Returns L extends R
? L<L>
: never
Logic for manipulating amounts.
Amounts are the canonical description of tradable goods. They are manipulated by issuers and mints, and represent the goods and currency carried by purses and payments. They can be used to represent things like currency, stock, and the abstract right to participate in a particular exchange.