xrpld
Loading...
Searching...
No Matches
Protocol.h
1#pragma once
2
3#include <xrpl/basics/ByteUtilities.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/protocol/Units.h>
6
7#include <mpt_protocol.h>
8#include <secp256k1_mpt.h>
9
10#include <cstddef>
11#include <cstdint>
12
13namespace xrpl {
14
27
30
33
36
39
42
48
51
54
57
60
71
88constexpr Bips32 kBipsPerUnity(100 * 100);
89static_assert(kBipsPerUnity == Bips32{10'000});
91static_assert(kTenthBipsPerUnity == TenthBips32(100'000));
92
93constexpr Bips32
95{
96 return Bips32(percentage * kBipsPerUnity.value() / 100);
97}
98constexpr TenthBips32
100{
101 return TenthBips32(percentage * kTenthBipsPerUnity.value() / 100);
102}
103template <typename T, class TBips>
104constexpr T
106{
107 return value * bips.value() / kBipsPerUnity.value();
108}
109template <typename T, class TBips>
110constexpr T
112{
113 return value * bips.value() / kTenthBipsPerUnity.value();
114}
115
116namespace Lending {
123static_assert(kMaxManagementFeeRate == TenthBips16(std::uint16_t(10'000u)));
124
130static_assert(kMaxCoverRate == TenthBips32(100'000u));
131
137static_assert(kMaxOverpaymentFee == TenthBips32(100'000u));
138
144static_assert(kMaxInterestRate == TenthBips32(100'000u));
145
152static_assert(kMaxLateInterestRate == TenthBips32(100'000u));
153
160static_assert(kMaxCloseInterestRate == TenthBips32(100'000u));
161
168static_assert(kMaxOverpaymentInterestRate == TenthBips32(100'000u));
169
179static constexpr int kLoanPaymentsPerFeeIncrement = 5;
180
203static constexpr int kLoanMaximumPaymentsPerTransaction = 100;
204} // namespace Lending
205
208
211
214
217
220
223
226
229
233
236
238constexpr std::uint64_t kMaxMpTokenAmount = 0x7FFF'FFFF'FFFF'FFFFull;
239static_assert(Number::kMaxRep >= kMaxMpTokenAmount);
240
243
246
253
257
260
262
264bool
266
268bool
270
275using TxID = uint256;
276
281
284
287
290
293
298
302
305constexpr std::size_t kMaxTrim = 25;
306
310
313
315constexpr std::size_t kEcScalarLength = kMPT_SCALAR_SIZE;
316
319
321constexpr std::size_t kEcCiphertextComponentLength = kMPT_ELGAMAL_CIPHER_SIZE;
322
324constexpr std::size_t kEcGamalEncryptedTotalLength = kMPT_ELGAMAL_TOTAL_SIZE;
325
327constexpr std::size_t kEcPubKeyLength = kMPT_PUBKEY_SIZE;
328
330constexpr std::size_t kEcPrivKeyLength = kMPT_PRIVKEY_SIZE;
331
333constexpr std::size_t kEcBlindingFactorLength = kMPT_BLINDING_FACTOR_SIZE;
334
336constexpr std::size_t kEcSchnorrProofLength = kMPT_SCHNORR_PROOF_SIZE;
337
339constexpr std::size_t kEcPedersenCommitmentLength = kMPT_PEDERSEN_COMMIT_SIZE;
340
342constexpr std::size_t kEcSingleBulletproofLength = kMPT_SINGLE_BULLETPROOF_SIZE;
343
345constexpr std::size_t kEcDoubleBulletproofLength = kMPT_DOUBLE_BULLETPROOF_SIZE;
346
348constexpr std::size_t kEcSendSigmaProofLength = SECP256K1_COMPACT_STANDARD_PROOF_SIZE;
349
352
354constexpr std::size_t kEcConvertBackSigmaProofLength = SECP256K1_COMPACT_CONVERTBACK_PROOF_SIZE;
355
359
361constexpr std::size_t kEcClawbackProofLength = SECP256K1_COMPACT_CLAWBACK_PROOF_SIZE;
362
365
368
371
372} // namespace xrpl
static constexpr internalrep kMaxRep
Definition Number.h:319
constexpr value_type value() const
Returns the underlying value.
Definition Units.h:323
static constexpr int kLoanMaximumPaymentsPerTransaction
Maximum number of combined payments that a LoanPay transaction will process.
Definition Protocol.h:203
constexpr TenthBips32 kMaxCloseInterestRate
The maximum close interest rate charged for repaying a loan early in 1/10 bips.
Definition Protocol.h:159
constexpr TenthBips32 kMaxOverpaymentFee
The maximum overpayment fee on a loan in 1/10 bips.
Definition Protocol.h:136
constexpr TenthBips32 kMaxOverpaymentInterestRate
The maximum overpayment interest rate charged on loan overpayments in 1/10 bips.
Definition Protocol.h:167
constexpr TenthBips16 kMaxManagementFeeRate(unsafeCast< std::uint16_t >(percentageToTenthBips(10).value()))
The maximum management fee rate allowed by a loan broker in 1/10 bips.
constexpr TenthBips32 kMaxInterestRate
Annualized interest rate of the Loan in 1/10 bips.
Definition Protocol.h:143
constexpr TenthBips32 kMaxLateInterestRate
The maximum premium added to the interest rate for late payments on a loan in 1/10 bips.
Definition Protocol.h:151
constexpr TenthBips32 kMaxCoverRate
The maximum coverage rate required of a loan broker in 1/10 bips.
Definition Protocol.h:129
static constexpr int kLoanPaymentsPerFeeIncrement
LoanPay transaction cost will be one base fee per X combined payments.
Definition Protocol.h:179
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr std::size_t kEcPubKeyLength
Length of EC public key (compressed).
Definition Protocol.h:327
constexpr std::uint8_t kEcCompressedPrefixEvenY
Compressed EC point prefix for even y-coordinate.
Definition Protocol.h:367
bool isFlagLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a flag ledgerIndex.
Definition Protocol.cpp:11
constexpr std::size_t kDirNodeMaxEntries
The maximum number of entries per directory page.
Definition Protocol.h:41
constexpr std::size_t kEcBlindingFactorLength
Length of the EC blinding factor in bytes.
Definition Protocol.h:333
constexpr std::size_t kMaxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.
Definition Protocol.h:225
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:259
constexpr std::size_t kMaxPriceScale
The maximum price scaling factor.
Definition Protocol.h:301
constexpr std::size_t kCompressedEcPointLength
Length of EC point (compressed).
Definition Protocol.h:318
constexpr T bipsOfValue(T value, Bips< TBips > bips)
Definition Protocol.h:105
constexpr TenthBips32 percentageToTenthBips(std::uint32_t percentage)
Definition Protocol.h:99
constexpr std::uint32_t kConfidentialFeeMultiplier
Extra base fee multiplier charged to confidential MPT transactions.
Definition Protocol.h:364
constexpr std::size_t kMaxBatchTxCount
The maximum number of transactions that can be in a batch.
Definition Protocol.h:312
constexpr T tenthBipsOfValue(T value, TenthBips< TBips > bips)
Definition Protocol.h:111
constexpr std::size_t kMaxTokenUriLength
The maximum length of a URI inside an NFT.
Definition Protocol.h:207
constexpr std::size_t kTxMinSizeBytes
Protocol specific constants.
Definition Protocol.h:26
constexpr std::size_t kPermissionMaxSize
The maximum number of delegate permissions an account can grant.
Definition Protocol.h:309
constexpr std::size_t kEcClawbackProofLength
Length of the ZKProof for ConfidentialMPTClawback.
Definition Protocol.h:361
constexpr std::uint8_t kVaultMaximumIouScale
Maximum scale factor for a Vault.
Definition Protocol.h:252
constexpr std::uint8_t kEcCompressedPrefixOddY
Compressed EC point prefix for odd y-coordinate.
Definition Protocol.h:370
Bips< std::uint32_t > Bips32
Definition Units.h:435
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > unsafeCast(Src s) noexcept
Definition safe_cast.h:52
constexpr std::size_t kEcSchnorrProofLength
Length of Schnorr ZKProof for public key registration (compact form) in bytes.
Definition Protocol.h:336
constexpr std::size_t kMaxLastUpdateTimeDelta
The maximum allowed time difference between lastUpdateTime and the time of the last closed ledger.
Definition Protocol.h:297
constexpr std::size_t kEcGamalEncryptedTotalLength
EC ElGamal ciphertext length: two compressed EC points concatenated.
Definition Protocol.h:324
constexpr std::size_t kMaxDidDataLength
The maximum length of an Attestation inside a DID.
Definition Protocol.h:216
TenthBips< std::uint32_t > TenthBips32
Definition Units.h:439
constexpr std::uint64_t kDirNodeMaxPages
The maximum number of pages allowed in a directory.
Definition Protocol.h:47
TenthBips< std::uint16_t > TenthBips16
Definition Units.h:438
constexpr std::uint16_t kMaxDeletableAmmTrustLines
The maximum number of trustlines to delete as part of AMM account deletion cleanup.
Definition Protocol.h:280
constexpr Bips32 kBipsPerUnity(100 *100)
There are 10,000 basis points (bips) in 100%.
constexpr std::size_t kMaxDataPayloadLength
The maximum length of Data payload.
Definition Protocol.h:242
constexpr std::size_t kEcConvertBackProofLength
128 bytes compact sigma proof + 688 bytes single bulletproof.
Definition Protocol.h:357
constexpr std::size_t kExpiredOfferRemoveLimit
The maximum number of expired offers to delete at once.
Definition Protocol.h:35
constexpr std::size_t kMaxDidUriLength
The maximum length of a URI inside a DID.
Definition Protocol.h:213
constexpr std::size_t kMaxDeletableTokenOfferEntries
The maximum number of offers in an offer directory for NFT to be burnable.
Definition Protocol.h:59
constexpr TenthBips32 kTenthBipsPerUnity(kBipsPerUnity.value() *10)
bool isVotingLedger(LedgerIndex seq)
Returns true if the given ledgerIndex is a voting ledgerIndex.
Definition Protocol.cpp:5
constexpr std::size_t kMaxOracleSymbolClass
The maximum length of a SymbolClass inside an Oracle.
Definition Protocol.h:292
constexpr auto megabytes(T value) noexcept
constexpr std::size_t kEcConvertBackSigmaProofLength
Length of the compact sigma proof component for ConfidentialMPTConvertBack.
Definition Protocol.h:354
constexpr std::uint8_t kVaultDefaultIouScale
Default IOU scale factor for a Vault.
Definition Protocol.h:248
constexpr std::size_t kEcSingleBulletproofLength
Length of single bulletproof (range proof for 1 commitment) in bytes.
Definition Protocol.h:342
constexpr std::size_t kMaxCredentialsArraySize
The maximum number of credentials can be passed in array.
Definition Protocol.h:228
constexpr std::size_t kEcPedersenCommitmentLength
Length of Pedersen Commitment (compressed).
Definition Protocol.h:339
constexpr std::size_t kEcCiphertextComponentLength
Length of one compressed EC point component in an EC ElGamal ciphertext.
Definition Protocol.h:321
constexpr std::uint8_t kMaxAssetCheckDepth
Maximum recursion depth for vault shares being put as an asset inside another vault; counted from 0.
Definition Protocol.h:256
constexpr std::size_t kMaxOracleProvider
The maximum length of a Provider inside an Oracle.
Definition Protocol.h:286
constexpr std::size_t kMaxDidDocumentLength
The maximum length of a Data element inside a DID.
Definition Protocol.h:210
constexpr std::size_t kMaxMpTokenMetadataLength
The maximum length of MPTokenMetadata.
Definition Protocol.h:235
constexpr std::size_t kEcSendSigmaProofLength
Length of the compact sigma proof component for ConfidentialMPTSend.
Definition Protocol.h:348
constexpr std::size_t kEcDoubleBulletproofLength
Length of double bulletproof (range proof for 2 commitments) in bytes.
Definition Protocol.h:345
constexpr std::size_t kMaxTokenOfferCancelCount
The maximum number of token offers that can be canceled at once.
Definition Protocol.h:56
constexpr std::size_t kMaxOracleUri
The maximum length of a URI inside an Oracle.
Definition Protocol.h:283
constexpr std::size_t kMaxTrim
The maximum percentage of outliers to trim.
Definition Protocol.h:305
constexpr Bips32 percentageToBips(std::uint32_t percentage)
Definition Protocol.h:94
constexpr std::size_t kEcScalarLength
Length of a secp256k1 scalar in bytes.
Definition Protocol.h:315
constexpr std::uint16_t kMaxTransferFee
The maximum token transfer fee allowed.
Definition Protocol.h:70
constexpr std::size_t kMaxCredentialUriLength
The maximum length of a URI inside a Credential.
Definition Protocol.h:222
constexpr std::size_t kEcSendProofLength
192 bytes compact sigma proof + 754 bytes double bulletproof.
Definition Protocol.h:351
unit::ValueUnit< unit::BipsTag, T > Bips
Definition Units.h:433
constexpr std::size_t kDirMaxTokensPerPage
The maximum number of items in an NFT page.
Definition Protocol.h:50
constexpr std::uint8_t kVaultStrategyFirstComeFirstServe
Vault withdrawal policies.
Definition Protocol.h:245
constexpr std::size_t kMaxPermissionedDomainCredentialsArraySize
The maximum number of credentials can be passed in array for permissioned domain.
Definition Protocol.h:232
unit::ValueUnit< unit::TenthBipsTag, T > TenthBips
Definition Units.h:437
constexpr std::size_t kUnfundedOfferRemoveLimit
The maximum number of unfunded offers to delete at once.
Definition Protocol.h:32
constexpr std::size_t kOversizeMetaDataCap
The maximum number of metadata entries allowed in one transaction.
Definition Protocol.h:38
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
Definition Protocol.h:238
constexpr std::size_t kEcPrivKeyLength
Length of EC private key in bytes.
Definition Protocol.h:330
BaseUInt< 256 > uint256
Definition base_uint.h:562
uint256 TxID
A transaction identifier.
Definition Protocol.h:275
constexpr std::size_t kMaxDeletableDirEntries
The maximum number of owner directory entries for account to be deletable.
Definition Protocol.h:53
constexpr std::size_t kMaxOracleDataSeries
The maximum size of a data series array inside an Oracle.
Definition Protocol.h:289
constexpr std::size_t kMaxDomainLength
The maximum length of a domain.
Definition Protocol.h:219
constexpr std::size_t kTxMaxSizeBytes
Largest legal byte size of a transaction.
Definition Protocol.h:29
constexpr std::uint32_t kFlagLedgerInterval
Definition Protocol.h:261