trustless-sidechain-8.0.0: Smart contract code used by the partner-chains project.
Safe HaskellSafe-Inferred
LanguageHaskell2010

TrustlessSidechain.Reserve

Description

 
Synopsis

Reserve validator

  • All redeemers require a Reserve UTXO input carrying a Reserve Auth token.
  • All redeemers except Handover require a Reserve UTXO output carrying a Reserve Auth token.
  • The Reserve UTXO must have `VersionedGenericDatum ReserveDatum` as its datum.
  • The Reserve UTXO carries native tokens, the AssetClass of which is specified in ImmutableReserveSettings in the datum.

Redeemers:

  1. DepositToReserve allows depositing native tokens into the Reserve.

    • It is a governance action (see approvedByGovernance).
    • Requires the output Reserve UTXO to carry the datum from the input Reserve UTXO unaltered.
    • Requires the output Reserve UTXO to carry more native tokens than the input Reserve UTXO.
    • Required reference inputs:

  2. TransferToIlliquidCirculationSupply allows transferring native tokens from the Reserve to the Illiquid Circulation Supply (ICS).

    • Total amount of tokens that can be released at any given time is determined by the so called V-function. This function is encoded as a minting policy. A transaction transferring native tokens to the ICS should mint V-function tokens with this minting policy. The validator requires that \(pcTokensTransferred = pcTokensTransferredUntilNow - numOfVtTokensMinted\).
    • Required reference inputs:

  3. UpdateReserve allows updating MutableReserveSettings in the Reserve UTXO.

  4. Handover allows transferring all remaining native tokens to the ICS, essentially ending the Reserve.

Error codes:

  • ERROR-RESERVE-01: Governance approval is not present
  • ERROR-RESERVE-02: Datum of the propagated reserve utxo changes
  • ERROR-RESERVE-03: Assets of the propagated reserve utxo don't increase by native tokens
  • ERROR-RESERVE-04: No unique input utxo carrying authentication token
  • ERROR-RESERVE-05: No unique output utxo at the reserve address and carrying authentication token
  • ERROR-RESERVE-06: Datum of input reserve utxo malformed
  • ERROR-RESERVE-07: Datum of output reserve utxo malformed
  • ERROR-RESERVE-08: Governance approval is not present
  • ERROR-RESERVE-09: Datum of the propagated reserve utxo changes not only by immutable settings
  • ERROR-RESERVE-10: Assets of the propagated reserve utxo change
  • ERROR-RESERVE-11: Assets of the propagated reserve utxo don't decrease by native tokens in desired way
  • ERROR-RESERVE-12: Datum of the propagated reserve utxo changes not only by stats in desired way
  • ERROR-RESERVE-13: Incorrect amount of native tokens goes into an illiquid circulation supply
  • ERROR-RESERVE-14: No unique output utxo at the illiquid circulation supply address
  • ERROR-RESERVE-15: Governance approval is not present
  • ERROR-RESERVE-16: An authentication token is not burnt
  • ERROR-RESERVE-17: Not all native tokens are transferred to illiquid circulation supply
  • ERROR-RESERVE-18: Continuing output exists without an authentication token

Reserve Auth token minting policy

Minting a Reserve Auth token initializes the Reserve.

  • It is a governance action (see approvedByGovernance).
  • Only a single token may be minted at once.
  • Minted token must go to an UTXO at the Reserve validator address, the Reserve UTXO.
  • The Reserve UTXO must be unique at the address and carry correct initial datum (where ReserveStats is 0).
  • Required reference inputs:

Burning Reserve Auth token is always allowed by the minting policy. In practice this can only happen in the Reserve validator Handover redeemer. The burning of the Reserve Auth token signifies the end of life for the Reserve.

Error codes:

  • ERROR-RESERVE-AUTH-01: Governance approval is not present
  • ERROR-RESERVE-AUTH-02: Single reserve authentication token is not minted
  • ERROR-RESERVE-AUTH-03: Output reserve UTxO doesn't carry auth token
  • ERROR-RESERVE-AUTH-04: Output reserve UTxO doesn't carry correct initial datum
  • ERROR-RESERVE-AUTH-05: No unique output UTxO at the reserve address
  • ERROR-RESERVE-AUTH-06: Output reserve UTxO carries no inline datum or malformed datum