pub fn encode_update_exchange_rate_script_function(
    currency: TypeTag,
    sliding_nonce: u64,
    new_exchange_rate_numerator: u64,
    new_exchange_rate_denominator: u64
) -> TransactionPayload
Expand description

Summary

Update the rough on-chain exchange rate between a specified currency and XDX (as a conversion to micro-XDX). The transaction can only be sent by the Treasury Compliance account. After this transaction the updated exchange rate will be used for normalization of gas prices, and for dual attestation checking.

Technical Description

Updates the on-chain exchange rate from the given Currency to micro-XDX. The exchange rate is given by new_exchange_rate_numerator/new_exchange_rate_denominator.

Parameters

NameTypeDescription
CurrencyTypeThe Move type for the Currency whose exchange rate is being updated. Currency must be an already-registered currency on-chain.
tc_accountsignerThe signer of the sending account of this transaction. Must be the Treasury Compliance account.
sliding_nonceu64The sliding_nonce (see: SlidingNonce) to be used for the transaction.
new_exchange_rate_numeratoru64The numerator for the new to micro-XDX exchange rate for Currency.
new_exchange_rate_denominatoru64The denominator for the new to micro-XDX exchange rate for Currency.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::NOT_PUBLISHEDSlidingNonce::ESLIDING_NONCEA SlidingNonce resource is not published under tc_account.
Errors::INVALID_ARGUMENTSlidingNonce::ENONCE_TOO_OLDThe sliding_nonce is too old and it’s impossible to determine if it’s duplicated or not.
Errors::INVALID_ARGUMENTSlidingNonce::ENONCE_TOO_NEWThe sliding_nonce is too far in the future.
Errors::INVALID_ARGUMENTSlidingNonce::ENONCE_ALREADY_RECORDEDThe sliding_nonce has been previously recorded.
Errors::REQUIRES_ADDRESSCoreAddresses::ETREASURY_COMPLIANCEtc_account is not the Treasury Compliance account.
Errors::REQUIRES_ROLERoles::ETREASURY_COMPLIANCEtc_account is not the Treasury Compliance account.
Errors::INVALID_ARGUMENTFixedPoint32::EDENOMINATORnew_exchange_rate_denominator is zero.
Errors::INVALID_ARGUMENTFixedPoint32::ERATIO_OUT_OF_RANGEThe quotient is unrepresentable as a FixedPoint32.
Errors::LIMIT_EXCEEDEDFixedPoint32::ERATIO_OUT_OF_RANGEThe quotient is unrepresentable as a FixedPoint32.
  • TreasuryComplianceScripts::update_dual_attestation_limit
  • TreasuryComplianceScripts::update_minting_ability